ktalebian Posted May 2, 2008 Share Posted May 2, 2008 Hi there! I am running WAMP on my computer, and I am getting an error: I have two files, and one is included in the other: page1.php <?php // doing stuff $_SESSION["name" ] = "something"; include("url)" // url of page2.php ?> page2.php <?php echo $_SESSION["name"]; ?> now, if the URL is in the format: http://localhost/path_to_page2.php , the $_SESSION["name"] becomes NULL in page2.php, and so I get nothing. But, if the url is in the format: page2.php or ../path_to_page2.php then it works fine. So that's ok, but then I get another problem. If want to include the url in the formation: page.php?page=stuff then I have to use the http://localhost/path_to_page2.php?page=stuff otherwise it says file not found, and if I use http, then the $_SESSION does not work! Help please! Why the hell is that happening? I have session_start() at the beginning of both pages btw. thanks! Link to comment https://forums.phpfreaks.com/topic/103933-session-problem/ Share on other sites More sharing options...
BlueSkyIS Posted May 2, 2008 Share Posted May 2, 2008 okay, include() must be a path, not a URL. you don't need to pass anything to an included file, so there is no use attaching ?page=stuff secondly, if one file is including another, only one of them should call session_start(); Link to comment https://forums.phpfreaks.com/topic/103933-session-problem/#findComment-532087 Share on other sites More sharing options...
ktalebian Posted May 4, 2008 Author Share Posted May 4, 2008 the reason I need to do the ?page= is because in the include file, I switch contents depending on the value of page! Link to comment https://forums.phpfreaks.com/topic/103933-session-problem/#findComment-532631 Share on other sites More sharing options...
helraizer Posted May 4, 2008 Share Posted May 4, 2008 I'm not sure if it's just a typo in your writing your code here but you have <?php include ("url)"; ?> You should really have <?php include ("url"); ?> Sam Link to comment https://forums.phpfreaks.com/topic/103933-session-problem/#findComment-532632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.