note 64462 added to function.session-write-close
| From: | junk at vhd dot com dot au | Date: | Fri, 14 Apr 2006 19:55:13 +0000 |
| Subject: | note 64462 added to function.session-write-close | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108104@lists.php.net to get a copy of this message | ||
I had a problem where some session variables were not carrying over to the other page.
The post by "risaac at deadletter dot com" gave me a clue. The session management does not
have enough time to write the changes to the session file (which for debian, the session files are
saved in /var/lib/php5).
A workaround I came up with is, at the end of the script do something like this:
$session_temp = $_SESSION;
session_write_close();
session_start();
$_SESSION = $session_temp;
session_write_close();
This is a bit crazy but it works. (I tried just using session_write_close(); without success. The
important bit seems to be restarting the session using session_start after closing the session using
session_write_close()).
I suspect that using the mm extension would avoid this problem, but it is not always available.
Alternatively, writing ones own session handler and storing the data in a database may avoid the
problem.
-------
Noticed a post on the main session manual page by "rciq at tlen dot pl"
who said:
> Don't do anything like:
> $_SESSION = $some_array;
> My php5.0.4 session stops without saving after such operations.
Not sure if this would apply to $_SESSION['foo'] = $some_array as well. However the fix I
mentioned at the begging will do the right thing regardless.
----
Server IP: 216.194.113.175
Probable Submitter: 68.220.67.226
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.session-write-close.php
Edit -- http://master.php.net/note/edit/64462
Del: integrated -- http://master.php.net/note/delete/64462/integrated
Del: useless -- http://master.php.net/note/delete/64462/useless
Del: bad code -- http://master.php.net/note/delete/64462/bad+code
Del: spam -- http://master.php.net/note/delete/64462/spam
Del: non-english -- http://master.php.net/note/delete/64462/non-english
Del: in docs -- http://master.php.net/note/delete/64462/in+docs
Del: other reasons-- http://master.php.net/note/delete/64462
Reject -- http://master.php.net/note/reject/64462
Search -- http://master.php.net/manage/user-notes.php