Looping through session data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ensnare

    Looping through session data

    Hi all,

    I'm using a database session handler and am looking to loop through
    data residing in the sessions table to make a 'Users online' array.

    I've found that using urldecode on the data column gives me a
    serialized string of varname|datatyp e:data; for each variable. I'm
    having a bit of trouble with deserializing the data.

    I could always use regexps to grab the specific data I want, but I'm
    sure there's a better way to do this. Any help is greatly appreciated.

    Thanks much!
  • steve

    #2
    Re: Looping through session data

    ensnare wrote:[color=blue]
    > Hi all,
    >
    > I’m using a database session handler and am looking to loop through
    > data residing in the sessions table to make a ’Users online’ array.
    >
    > I’ve found that using urldecode on the data column gives me a
    > serialized string of varname|datatyp e:data; for each variable. I’m
    > having a bit of trouble with deserializing the data.
    >
    > I could always use regexps to grab the specific data I want, but[/color]
    I’m[color=blue]
    > sure there’s a better way to do this. Any help is greatly[/color]
    appreciated.[color=blue]
    >
    > Thanks much![/color]
    PHP has a nice way of looping thru variables inside an array so with
    query string you can do something like this:

    foreach ($GET as $key => $value) {
    //not do something with $value[$key]...
    }

    same for cookies, $_PUT, $_SERVER, etc.

    --
    http://www.dbForumz.com/ This article was posted by author's request
    Articles individually checked for conformance to usenet standards
    Topic URL: http://www.dbForumz.com/PHP-Looping-...ict124156.html
    Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=413682

    Comment

    • Jochen Daum

      #3
      Re: Looping through session data

      Hi ensnare,

      On 28 Jun 2004 18:11:04 -0700, ensnare@gmail.c om (ensnare) wrote:
      [color=blue]
      >Hi all,
      >
      >I'm using a database session handler and am looking to loop through
      >data residing in the sessions table to make a 'Users online' array.
      >
      >I've found that using urldecode on the data column gives me a
      >serialized string of varname|datatyp e:data; for each variable. I'm
      >having a bit of trouble with deserializing the data.[/color]

      Have you tried unserialize()?

      HTh, Jochen
      --
      Jochen Daum - Cabletalk Group Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      Download PHP DB Edit Toolkit for free. PHP DB Edit Toolkit is a set of PHP classes makes the generation of database edit interfaces easier and faster. The main class builds tabular and form views based on a data dictionary and takes over handling of insert/update/delete and user input.

      Comment

      Working...