Re: Re: Sessions still do not persist

From: Date: Fri, 21 May 2004 19:02:32 +0000
Subject: Re: Re: Sessions still do not persist
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-186708@lists.php.net to get a copy of this message
On Fri, May 21, 2004 at 08:35:37PM +0200, Torsten Roehr wrote: > Sorry, I'm an idiot! The ? was missing: > > <form method="post" action="xxx.php?<?= SID; ?>"> > Well, I spoke too soon. It does work, but only the SECOND time the script is run! Stage:0 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca ______ [Submit] Stage:1 SessionID: 6c9a1819fe95fa6f08f385ee2afa71ca Request: Array ( ) Type "foo" into the form, hit submit and the session variable is not being preserved: Stage:0 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 foo___ [Submit] Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array ( [PHPSESSID] => 6c9a1819fe95fa6f08f385ee2afa71ca [field] => foo ) Type "bar" into the form, hit submit and the session variable IS being preserved: Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 bar___ [Submit] Stage:1 SessionID: ac429ad0086eb5b4d1130eb2e2fddcb9 Request: Array ( [PHPSESSID] => ac429ad0086eb5b4d1130eb2e2fddcb9 [field] => bar ) So, what am I missing here? Code, for reference: <? if (!isset($_SESSION['stage'])) { $_SESSION['stage'] = 0; } if (!isset($_POST['field'])) { $_POST['field'] = ""; } ?> <html> <head><title>PHP Test page</title></head> <body> <? echo "Stage:"; echo $_SESSION['stage']; echo " SessionID: "; echo session_id(); $_SESSION['stage'] = 1; ?> <form method="post" action="xxx.php?<?= SID; ?>"> <input type="text" maxlength="7" size="7" name="field" value="<?echo $_POST['field']?>"> <input type="submit" value="Submit"> </form> <? echo "Stage:"; echo $_SESSION['stage']; echo " "; echo " SessionID: "; echo session_id(); echo " "; echo " Request: "; print_r($_REQUEST); ?> </body> </html>

« previous php.general (#186708) next »