Re: session_decode from session handler
| From: | Jeffery Fernandez | Date: | Sun, 22 Jul 2007 04:19:07 +0000 |
| Subject: | Re: session_decode from session handler | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-259319@lists.php.net to get a copy of this message | ||
I have a similar problem I am facing with session data stored in the database
from the set_session_handler.
What I am trying to do is show a list of online users and the page they are
currenlty viewing. For this purpose I am query the sessions table to get the
list of session and from that I loop through to get the session data of each
online user. But for some reason, I cannot decode/un-serialise the session
data. Any pointers ?
cheers,
Jeffery
On Friday 20 July 2007 08:25, Ryan Graciano wrote:
> 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 <tijnema@gmail.com>
> To: Ryan Graciano <rmgraci@yahoo.com>
> 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 <rmgraci@yahoo.com> 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
--
Powered by openSUSE 10.2 (i586) Kernel: 2.6.18.8-0.5-default
KDE: 3.5.5 "release 45.4"
2:19pm up 11 days 18:32, 7 users, load average: 0.42, 0.58, 0.54