PHP passed $data to my write($id) function, and then I wrote it to the 
database.  In the code below, I have retrieved it from the database.  I presume 
that it used encode_session to generate $data.

I tried calling unserialize() on it for good measure, but it wasn't able to 
parse the data.  When I return $data from my method, though, PHP is able to 
turn it into a $_SESSION.

Thanks,
- Ryan

----- Original Message ----
From: Tijnema <[EMAIL PROTECTED]>
To: Ryan Graciano <[EMAIL PROTECTED]>
Cc: php-general@lists.php.net
Sent: Thursday, July 19, 2007 5:28:32 PM
Subject: Re: [PHP] session_decode from session handler

On 7/19/07, Ryan Graciano <[EMAIL PROTECTED]> wrote:
>
> I'm having an issue getting session_decode to work from my session handler in 
> PHP 5.2.3.  Here's a short code snippet that demonstrates what I'm trying to 
> do (from my read handler) -
>
> public function read($id) {
> ....
> var_dump($data);  // prints out the serialized session correctly
> $retval = session_decode($data);
> var_dump($_SESSION);  // prints out "array(0) {}"
> echo $retval;  // prints false
> return $data;
> }
>
> In my calling function, $_SESSION is updated with everything that was held in 
> $data, which means that $data was not corrupt - it worked when I returned it, 
> but it did not work when I used session_decode.  This is a problem because I 
> want to change my read($id) function so that it decodes $data, adds something 
> extra to the $_SESSION, then re-encodes $data and returns it.
>
> Thanks,
> - Ryan

How did you get $data?

If it's just serialized data, you can simply call unserialize instead
of session_decode.

Tijnema

-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info







       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

Reply via email to