www.webdeveloper.com
Results 1 to 4 of 4

Thread: Viewing all session variables

  1. #1
    Join Date
    Feb 2008
    Posts
    6

    Viewing all session variables

    Is there anyway in PHP to access all active Session variables?

  2. #2
    Join Date
    Sep 2006
    Location
    Bucharest, RO
    Posts
    940
    umm..
    PHP Code:
    print_r($_SESSION); 
    or maybe:
    PHP Code:
    foreach ($_SESSION as $key => $value) {
       echo 
    'Session var "' $key '" is equal to "' $value '"<br>';

    Does that help?

  3. #3
    Join Date
    Feb 2008
    Posts
    6
    Sorry, I phrased the question terribly. Can you see the session variables for the other browsers visiting the site. For example, can you get all the values of $_SESSION["userID"] to see which users are online?

  4. #4
    Join Date
    Sep 2006
    Location
    Bucharest, RO
    Posts
    940
    Short answer: No.

    Long(ish) answer: Yes, but it would be an immense headache. You would have to find the session files on the hard disk, try to open them, decode them and read the userID.

    I suppose you have a mysql table somewhere that holds your users? If not, create one and make sure it has a column with a timestamp which gets updated to NOW() on each pageview. Then, to show online users just show from that table users that have the timestamp set to NOW() - 5 minutes or more.

    If you need any help on that, let us know.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles