note 94475 deleted from function.session-write-close by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 14:46:28 +0000 |
| Subject: | note 94475 deleted from function.session-write-close by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162479@lists.php.net to get a copy of this message | ||
Note Submitter: marcel m
----
I have a script that redirected a user using header() to a new location and had to store session
data before the redirect takes place (not using cookies, just passing sid).
This was working perfectly fine in PHP4, but when using PHP5 the session file was stored with
variables not containing any values.
After hours of debugging, I found out that in my case the session keys didn't get saved with
any values, as I was using the underscore (_) sign in the session key.
eg
$test = "Value";
$_SESSION['my_variable'] = $test;
just stored an empty value in $_SESSION['my_variable'].
after omitting the _ sign and using
$_SESSION['myvariable'] = $test;
all problems were gone and the session was saved correctly before the header() redirect. It made no
difference if I was using session_write_close() before the header() call. The problem was just with
the _ sign in the key.