note 68341 added to ref.session
| From: | drs at berkeley dot edu | Date: | Mon, 24 Jul 2006 04:41:57 +0000 |
| Subject: | note 68341 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115070@lists.php.net to get a copy of this message | ||
I am reasonably confident I'm doing something wrong, but on the off chance that I'm wrong
about that...
I was losing $_SESSION between script calls. I would load it up like this:
<?php
$result = @mysql_query($query)
$data = mysql_fetch_array( $result ) ;
while ( list ( $key, $value ) = each ( $data ) )
$_SESSION[$key] = $value;
$_SESSION['valid_user'] = $logname;
session_write_close();
?>
and after a second call to the script the only thing left in $_SESSION would be the
'valid_user' entry, i.e. the one entered "manually", rather than by going
through the $data array.
Well... it turns out that $data has two sets of $values, one complete set indexed by strings, and
another indexed by integers. Having both sets loaded into $_SESSION seems to cause huge problems,
but if I do this:
<?php
while ( list ( $key, $value ) = each ( $data ) )
if ( ! is_numeric( $key ) )
$_SESSION[$key] = $value;
?>
then everything is magically all better.
*That* only took a few hours to figure out. Hope this helps someone.
*shrug*
--
drs
----
Server IP: 64.71.164.2
Probable Submitter: 71.132.130.150
----
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/ref.session.php
Edit -- http://master.php.net/note/edit/68341
Del: integrated -- http://master.php.net/note/delete/68341/integrated
Del: useless -- http://master.php.net/note/delete/68341/useless
Del: bad code -- http://master.php.net/note/delete/68341/bad+code
Del: spam -- http://master.php.net/note/delete/68341/spam
Del: non-english -- http://master.php.net/note/delete/68341/non-english
Del: in docs -- http://master.php.net/note/delete/68341/in+docs
Del: other reasons-- http://master.php.net/note/delete/68341
Reject -- http://master.php.net/note/reject/68341
Search -- http://master.php.net/manage/user-notes.php