On Sunday 22 July 2007 14:19, Jeffery Fernandez wrote:
> 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 ?

just following up on this problem. I am using PHP 5.2.3. I also do remember 
that previously in older versions of PHP, I used to see the session data was 
the actual serialised data. But now with my testing it just seems to be one 
long string. Which leads me to beleive that there is some kind of encoding 
taking place.

>
> 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 <[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
>
> --
> 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

-- 
Powered by openSUSE 10.2 (i586) Kernel: 2.6.18.8-0.5-default
KDE: 3.5.5 "release 45.4"
  2:24pm  up 11 days 18:38,  7 users,  load average: 0.45, 0.42, 0.47

Attachment: pgpMhC1sICAJ7.pgp
Description: PGP signature

Reply via email to