vesper Posted May 15, 2007 Share Posted May 15, 2007 hi, i am wondering if someone out there may be able to help? i have <?php session_start(); ?> as the very first line on the first page of my site. when i authenticate the user logon, i assign data read from the database to the session variables: $_SESSION['sessionVariable1'] = $row['dbData1']; $_SESSION['sessionVariable2'] = $row['dbData2']; $_SESSION['sessionVariable3'] = $row['dbData3']; $_SESSION['sessionVariable4'] = $row['dbData4']; the variable names above are just made up, not those in the actual code, but you get the idea. if i display the session variables using echo $_SESSION['sessionuserVariable1']; in the same page that I create them in there is no problem. however, once authentication has taken place the user is redirected using 'header'. the page the user is redirected to can not display the session variables! does anyone have any idea why it is doing this? Quote Link to comment https://forums.phpfreaks.com/topic/51483-subsequent-page-not-reading-session-variable/ Share on other sites More sharing options...
jitesh Posted May 15, 2007 Share Posted May 15, 2007 Have every pages where are you are using session contains "session_start();" ? If not then mention "session_start()" at first line of every pages. Quote Link to comment https://forums.phpfreaks.com/topic/51483-subsequent-page-not-reading-session-variable/#findComment-253515 Share on other sites More sharing options...
vesper Posted May 15, 2007 Author Share Posted May 15, 2007 Have every pages where are you are using session contains "session_start();" ? If not then mention "session_start()" at first line of every pages. hi, thanks for replying. no they don't. only the first page (index.php) contains "session_start()". i'll give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/51483-subsequent-page-not-reading-session-variable/#findComment-253517 Share on other sites More sharing options...
vesper Posted May 15, 2007 Author Share Posted May 15, 2007 hi jitesh, it works now! i would have thought that adding session_start(); to every page would start a new session!?!? thanks for your help!! Quote Link to comment https://forums.phpfreaks.com/topic/51483-subsequent-page-not-reading-session-variable/#findComment-253518 Share on other sites More sharing options...
jitesh Posted May 15, 2007 Share Posted May 15, 2007 if no session id is set then it will take existing session id then you will continue with last sesssion. If you want to pass session id then mention session_id('The session id'); before session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/51483-subsequent-page-not-reading-session-variable/#findComment-253524 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.