note 74772 modified in function.session-write-close by nlopess
| From: | nlopess@php.net | Date: | Tue, 15 May 2007 13:44:59 +0000 |
| Subject: | note 74772 modified in function.session-write-close by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126608@lists.php.net to get a copy of this message | ||
I was having trouble with session data being lost / not carrying over to other pages when using
header("Location: ..."), and session_write_close() was not helping.
I was writing to $_SESSION by doing:
$_SESSION = $myArray;
I eventually found that doing it this way helped:
foreach($myArray as $k => $v)
{
$_SESSION[$k] = $v;
}
The problem was strange; I've assigned arrays to $_SESSION countless times and never had
trouble with it. In fact, I was doing it in many places elsewhere in the same application, and I
never ran into any problems.
I spent hours figuring out what was happening. Hope this saves time for somebody out there.
--was--
I was having trouble with session data being lost / not carrying over to other pages when using
header("Location: ..."), and session_write_close() was not helping.
I was writing to $_SESSION by doing:
$_SESSION = $myArray;
I eventually found that doing it this way helped:
foreach($myArray as $k => $v)
{
$_SESSION[$k] = $v;
}
The problem was strange; I've assigned arrays to $_SESSION countless times and never had
trouble with it. In fact, I was doing it in many places elsewhere in the same application, and I
never ran into any problems.
I spent hours figuring out what was happening. Hope this saves time for somebody out there.
http://php.net/manual/en/function.session-write-close.php