phpshift Posted August 23, 2009 Share Posted August 23, 2009 I have two pages on the same domain in the same directory. I am simply using session_start() at the top of my pages, not linking pages with ?SID or anything like that. I have two pages and when I check session_id(), I get the same value on both pages. But I used a foreach() to show all the session variables and the two pages have different variables showing up. Does anyone know any reason that this would be happening and how to fix it? I'm trying to set up a signup that spans multiple pages and after a couple pages, it's losing the variables for some reason. Any help would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/ Share on other sites More sharing options...
ignace Posted August 23, 2009 Share Posted August 23, 2009 Have you used session_start(); on both pages? Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-904353 Share on other sites More sharing options...
phpshift Posted August 23, 2009 Author Share Posted August 23, 2009 Yes, I've used session_start() as the first thing at the top of both pages. Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-904355 Share on other sites More sharing options...
ignace Posted August 23, 2009 Share Posted August 23, 2009 Please post your code of both pages or atleast the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-904359 Share on other sites More sharing options...
markwillis82 Posted August 23, 2009 Share Posted August 23, 2009 you may find that if you have ALL cookies disabled (including session cookies) you will get a new session on every page load. Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-904361 Share on other sites More sharing options...
phpshift Posted August 23, 2009 Author Share Posted August 23, 2009 Well, right now, they're both running the same exact script for debugging. All the variables used for both were set in the same session but they come up different. Here is my debugging code: session_start(); print session_id()."<br>"; foreach($_SESSION as $k=>$v) { print "\$_SESSION[\"".$k."\"]=\"".$v."\";<br>"; } die(); The results for the first page: 96bddc7f6b567feecf259efe354f7694 $_SESSION["sessiontest"]="Sessions work"; $_SESSION["npr_step"]="0"; $_SESSION["dynamicID"]="c51ce410c124a10e0db5e4b97fc2af39"; $_SESSION["image_location"]="068004fef1759529ff6f29015cde17cd3d36cae69bf7face8bc5b10f5d50db67.png"; And the second: 96bddc7f6b567feecf259efe354f7694 $_SESSION["npr_step"]="2"; $_SESSION["uniqueID"]="940392f5f32a7ade1cc201767cf83e313c6d2f0916bd1e44c75cbe82fb29d95eeb5b26b95721336140a6af3cd092da02a536fb5480db8bdbb84daffe345c675b"; @markwillis82 I thought about that and checked. My cookies are set to accept all. Also, two of my pages are reading the same session variables just fine. But it seems that after those two pages, it forgets the variables whether I run other scripts or not. Also, all pages return the same session ID. Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-904362 Share on other sites More sharing options...
phpshift Posted August 25, 2009 Author Share Posted August 25, 2009 Has anyone seen this before? I don't understand at all how it works. Shouldn't it just be reading the file from the server with the SID it returned? And if so, shouldn't both pages be reading the same file and returning the same result? Quote Link to comment https://forums.phpfreaks.com/topic/171494-session-returns-different-variables-with-same-sid/#findComment-906107 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.