Jump to content

Sessions not working in include file


cstegner

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

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

content here

<?
include("http://www.bigornot.com/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?
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.