SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Scary's On The Wall
    Join Date
    Apr 2003
    Location
    PA
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session Arrays - Is it possible?

    Can you store an array to a session variable? For example:

    $val = array(rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000));
    $_SESSION['val'] = $val;

    and then retrieve it like this:

    $_SESSION['val[0]']

    Thank you in advance for your response! 8)

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    You can access the values via

    $_SESSION['val'][0] ... $_SESSION['val'][n]

  3. #3
    Scary's On The Wall
    Join Date
    Apr 2003
    Location
    PA
    Posts
    518
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ohhh...

    Can I still store them the same way?

  4. #4
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes,

    if you use:

    PHP Code:
    $val = array(rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000),rand(1,10000));
    $_SESSIOn['val'] = $val
    you can access each array element using the way I described above.

  5. #5
    As the name suggests... trickie's Avatar
    Join Date
    Jul 2002
    Location
    Melbourne, Australia
    Posts
    678
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can put anything you want in a session (dunno about filepointers or sockets though??). Everything is serialized:
    http://www.php.net/manual/en/function.serialize.php


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •