Jump to content


This topic is now archived and is closed to further replies.


Sessions not working in include file

Recommended Posts

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


content here


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?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.