kr3m3r Posted August 21, 2007 Share Posted August 21, 2007 In my last posting someone suggested using session start() to pass a variable through multiple php pages using the $_SESSION['x']=$x;. I don't quite understand how to do it. Another individual suggested using hidden fields in your form which I'm not sure how to do either. Any help with this would be really appreciated. -Robb Quote Link to comment https://forums.phpfreaks.com/topic/66013-solved-how-does-session_start-work/ Share on other sites More sharing options...
supermerc Posted August 21, 2007 Share Posted August 21, 2007 well what do you want to pass? If its something from ur database you do ur query, then like $_SESSION['whatever'] = $whatever; So now in anypage where your session is started and you call the $_SESSION['whatever'] variable it will give you $whatever Quote Link to comment https://forums.phpfreaks.com/topic/66013-solved-how-does-session_start-work/#findComment-330093 Share on other sites More sharing options...
kr3m3r Posted August 21, 2007 Author Share Posted August 21, 2007 I'm trying to pass a variable from the first page (tells me what type of item they are going to enter [dvd,cd,book]) i'm writing through the second page (where they enter all the pertinent information [title author etc.]) into a third page where the items are submitted into the database. I guess part of the question was, in the sticky posted above, they said header errors occured due to where something like session_start() was posted. I'm just not clear on what they meant. Thanks, -Robb Quote Link to comment https://forums.phpfreaks.com/topic/66013-solved-how-does-session_start-work/#findComment-330096 Share on other sites More sharing options...
tlavelle Posted August 21, 2007 Share Posted August 21, 2007 Session variables allow you to capture user entered values for the duration of the users session. At the top of all the pages in your app, make sure you include <?php session_start(); ?> This basically allows you to invoke the session array. So if a user posts a value from a form you can assign it to $_SESSION['dvd']; Then for the duration of the session, that variable will be available in that array. Quote Link to comment https://forums.phpfreaks.com/topic/66013-solved-how-does-session_start-work/#findComment-330102 Share on other sites More sharing options...
supermerc Posted August 21, 2007 Share Posted August 21, 2007 No what the sticky said is output errors may be do to session start but thats not your problem. On your first page you start the session, then set the session thing like i told you to their choice, then all you do is start the session in all your other pages and you can call it when ever you want as long as your session is started. Quote Link to comment https://forums.phpfreaks.com/topic/66013-solved-how-does-session_start-work/#findComment-330104 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.