pinacoladaxb Posted September 14, 2008 Share Posted September 14, 2008 I can't get sessions to work. I made a small example on my site: http://www.atomicriot.com/test/test1.php Code for test1.php: <?php session_start(); $_SESSION['test'] = 23; echo "Establishing session...<br />"; if ($_SESSION['test'] == 23) echo "Session created. The value 23 was stored in the variable "test"."; else echo "Session was not created."; echo "<p><a href=\"../test/test2.php\">Click Here</p>"; ?> Code for test2.php: <?php if(isset($_SESSION['test'])) echo $_SESSION['test']; else echo "The variable "test" was not set."; ?> Am I missing something? Please help. Quote Link to comment https://forums.phpfreaks.com/topic/124234-quick-question-about-sessions/ Share on other sites More sharing options...
Adam Posted September 14, 2008 Share Posted September 14, 2008 Yes you need session_start(); on every page you use sessions... Adam Quote Link to comment https://forums.phpfreaks.com/topic/124234-quick-question-about-sessions/#findComment-641525 Share on other sites More sharing options...
pinacoladaxb Posted September 14, 2008 Author Share Posted September 14, 2008 Ooooh. That would explain it. Thanks, Adam. -Adam Quote Link to comment https://forums.phpfreaks.com/topic/124234-quick-question-about-sessions/#findComment-641527 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.