Jump to content

Session variables do not persist into included files


gmwebs

Recommended Posts

Hi,

 

I just can't seem to get this to work...

 

In my index.php file I set a session variable

 

$_SESSION['product'] = "foo";

 

and then in my html part of index.php I include a file menu.php using require_once() which I use to build the menu tree. However, the session variable is not available to me inside that include file. It is available to me inside index.php because if I echo it I can see it. If I go to page2.php it is also there. Just not in the include file.

 

Am I doing something stupid here??

 

Graham

 

 

Sorry, I am at work at the moment, but if I remember correctly I am doing it the following way...

 


//index.php

session_start();

$_SESSION['product'] = "foo";

require_once($_SERVER['DOCUMENT_ROOT'] . "/includes/menu.inc.php");

Archived

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

×
×
  • 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.