Jump to content


Photo

Sessions not working in include file


  • Please log in to reply
3 replies to this topic

#1 cstegner

cstegner
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 20 April 2006 - 04:39 PM

I have redone my whole site in CSS instead of tables and made it XHTML compliant. So now I wanted to just take the main design and chop it into two pieces; top.php and bottom.php.

Then I

<?php
session_start();
include("http://www.bigornot....om/inc/top.php");
?>

content here

<?
include("http://www.bigornot....inc/bottom.php");
?>

However none of the sessions appear to be carrying over to the files I am including. General stuff like $username. How do we get past this?

#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 20 April 2006 - 04:56 PM

By waht I have studied all the superglobal variables, always hold the variables in them, You can probably change around variable information with basic string functions, and replace functions, but you would have to find the position of the variable first.

what you could try is saving it as a function in an external php file, and then running the function on the page you want.

[a href=\"http://www.hudzilla.org/phpbook/read.php/4_18_0\" target=\"_blank\"]http://www.hudzilla.org/phpbook/read.php/4_18_0[/a]
on this site, it cuts down the informaiton on superglobals and there usage a lot better than www.w3schools.com and the manual at php.net so maybe you can find something there.

[a href=\"http://www.hudzilla.org/phpbook/read.php/2_6_15\" target=\"_blank\"]http://www.hudzilla.org/phpbook/read.php/2_6_15[/a]
also this page exactly gives detailed information on including files, and splicing up file information.

Or you can take the top portion, put it in top.php, the bottom put it in bottom.php and call each one where they are needed in the main document.

Or maybe storing the variable you are trying to carry over into a function in an external file like I stated earlier, but then use the function in the file you are wanting to carry if over for, or just reset the variable.

some of this sounds wierd because I misunderstood your post at first but hopefully something here can help.

I also notice a database insert error on the section
[a href=\"http://www.bigornot.com/inc/bottom.php\" target=\"_blank\"]http://www.bigornot.com/inc/bottom.php[/a]
near the bottom of the page, maybe that has something to do with it,.

also the variable for username should be stored in one of the superglobals I am not sure which one it said, put that variable should be able to be moved throughout the same server seamlessly, by what I have read.

hope some of this helps.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#3 cstegner

cstegner
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 20 April 2006 - 05:35 PM

duh figure it out....

Since I was calling it with the entire url it must have rendered the include before including it.

So I just used a server path and it works perfect.

Thanks for the help though.

-Chris

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 20 April 2006 - 06:15 PM

your welcome

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users