gmwebs Posted March 18, 2007 Share Posted March 18, 2007 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 Link to comment https://forums.phpfreaks.com/topic/43293-session-variables-do-not-persist-into-included-files/ Share on other sites More sharing options...
kenrbnsn Posted March 19, 2007 Share Posted March 19, 2007 Please show us how you're including the file. Ken Link to comment https://forums.phpfreaks.com/topic/43293-session-variables-do-not-persist-into-included-files/#findComment-210270 Share on other sites More sharing options...
gmwebs Posted March 19, 2007 Author Share Posted March 19, 2007 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"); Link to comment https://forums.phpfreaks.com/topic/43293-session-variables-do-not-persist-into-included-files/#findComment-210397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.