$_SESSION var sometimes set, sometimes not

From: Date: Tue, 25 Nov 2003 02:32:44 +0000
Subject: $_SESSION var sometimes set, sometimes not
Groups: php.general 
Request: Send a blank email to php-general+get-170838@lists.php.net to get a copy of this message
Hi, The following code sometimes produces output indicating that the session variables have been set, and sometimes is says that they have not been set. Unfortunately the server is not mine to configure, but if there is a problem with it, I can get in touch with the right people. Is the script properly written? Is it a server problem? <html> <head> <title>Test stuff...</title> </head> <body> <?php session_start(); // enable session level global variables if (isset($_POST['action']) && $_POST['action'] == 'sub1' ) sub1(); else { session_unset(); // all variables start fresh here $_SESSION['test']='HERE I AM!<br>'; echo $_SESSION['test']; print_r ($_SESSION); } function sub1() { echo "sub1 routine<br>"; print_r ($_SESSION); if ( isset($_SESSION['test']) ) echo $_SESSION['test']; else echo 'variable not set<br>'; } //////////////////////////////////////////////////////////////////////////// /// ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <select name="sub1"> <option> sub1 </option><br> </select> <input type="hidden" name="action" value="sub1"> <input type="submit" name="submit" value="go"> </form> </body> </html>

« previous php.general (#170838) next »