paulman888888 Posted July 18, 2008 Share Posted July 18, 2008 Hi. I am new to sessions and would like to learn about it. Reason being i would like to some script that puts $_POST[] into a session. Thankyou Paul Quote Link to comment Share on other sites More sharing options...
Guest Xanza Posted July 18, 2008 Share Posted July 18, 2008 read here endless information. Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted July 18, 2008 Author Share Posted July 18, 2008 so do sessions automaticly go to the next page? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 18, 2008 Share Posted July 18, 2008 You need to put <?php session_start(); ?> at the start of each script where you want to use sessions. Ken Quote Link to comment Share on other sites More sharing options...
HelpMe1985 Posted July 18, 2008 Share Posted July 18, 2008 you can post stuff over from other pages if thats what your getting at ? Quote Link to comment Share on other sites More sharing options...
paulman888888 Posted July 18, 2008 Author Share Posted July 18, 2008 Just to clarify. Page 1 <?php session_start(); //then loads of session stuff ?> Page 2 <?php session_start(); //the session variables has been past on from page 1 ?> Page 3 <?php session_start(); //will the variables from Page 2 still come though to this Page? ?> Thankyou Paul Quote Link to comment Share on other sites More sharing options...
Lautarox Posted July 18, 2008 Share Posted July 18, 2008 When you start a session on the page, it loads automatically the $_SESSION array with the values you gave it, if the session is still alive.. so it will load the session values in the 3rd page Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 18, 2008 Share Posted July 18, 2008 The $_SESSION array will contain everything that you put into it from which ever script. It's cumulative. By default the session goes away when you close the browser. Try these three scripts: one.php <?php session_start(); echo '<pre>' . print_r($_SESSION,true) . '</pre>'; if (isset($_SESSION['one'])) $_SESSION['one']++; else $_SESSION['one'] = 1; ?> two.php <?php session_start(); echo '<pre>' . print_r($_SESSION,true) . '</pre>'; if (isset($_SESSION['two'])) $_SESSION['two']++; else $_SESSION['two'] = 1; ?> three.php <?php session_start(); echo '<pre>' . print_r($_SESSION,true) . '</pre>'; if (isset($_SESSION['three'])) $_SESSION['three']++; else $_SESSION['three'] = 1; ?> Invoke them in any order in the same browser and see how the $_SESSION array changes. Ken Quote Link to comment 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.