maliary Posted June 20, 2007 Share Posted June 20, 2007 Hi, I have this variable that is passed in the the $_GET, which I then assign it to a $_SESSION variable to ensure persistency, however every time i reload the page the $_SESSION variable gets lost. Hence unusable. $_SESSION ['very'] = $_GET['pery']; How can I ensure persistency beyond page reloads? Quote Link to comment Share on other sites More sharing options...
papaface Posted June 20, 2007 Share Posted June 20, 2007 Try if (!$_SESSION['very']) { if ($_GET['pery']) { $_SESSION['very'] = $_GET['pery']; } } Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 20, 2007 Share Posted June 20, 2007 In any page you want to use that session variable.... <?php session_start(); $very = $_SESSION ['very']; echo $very; //Should still output a value even on diferent pages; ?> Though you can also look into constants....doing this once....it has been defined and it's value won't change....so it depends on your script and logic in terms of what approach would be best. <?php define('VERY_DEFINED', $your_value); ?> Edit: But you must initiate the session (session_start()) before using the session variable in other pages. 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.