woody79 Posted August 13, 2008 Share Posted August 13, 2008 I have a page that sets a two sessions and one that reads them. The page that reads them looks like this: <?php session_start(); if (isset($_SESSION['maxauth'])) { print_r(unserialize($_SESSION['maxinfo'])); } else { echo "No"; } ?> When I refresh the page it sometimes gives me print_r(unserialize($_SESSION['maxinfo'])); , but otherwise No. I have refreshed the page 10 times and 2 times out of 10 the session was recognized. My dev server (Windows-PHP5) gets 10 out of 10, but my actual host (Unix-PHP4) gets 2 out of 10. Why is this? Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/ Share on other sites More sharing options...
discomatt Posted August 13, 2008 Share Posted August 13, 2008 Could be a cookie issue? Is this isolated to your machine or a problem with multiple clients? Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/#findComment-615430 Share on other sites More sharing options...
DeanWhitehouse Posted August 13, 2008 Share Posted August 13, 2008 echo session_id(); under session_start(); and check if that shows all ten times. Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/#findComment-615439 Share on other sites More sharing options...
woody79 Posted August 13, 2008 Author Share Posted August 13, 2008 I performed that little test and the session id shows all the time. Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/#findComment-615456 Share on other sites More sharing options...
DeanWhitehouse Posted August 13, 2008 Share Posted August 13, 2008 Ok, so that means the session start is always there, have you checked if the session is there try session_start(); echo $_SESSION['maxinfo']; Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/#findComment-615588 Share on other sites More sharing options...
geudrik Posted August 13, 2008 Share Posted August 13, 2008 Aye, make sure your session variable is actually declared. Quote Link to comment https://forums.phpfreaks.com/topic/119454-php-session-not-always-being-recognized/#findComment-615608 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.