Re: List of sessions

From: Date: Sat, 06 May 2006 22:39:20 +0000
Subject: Re: List of sessions
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-235686@lists.php.net to get a copy of this message
On 5/7/06, tedd <tedd@sperling.com> wrote:
Hi: While we're on the subject of listing sessions, what does the following code do? session_start(); $path = ini_get('session.save_path'); $handle = dir($path); while ($filename = $handle->read())
        {
          if (substr($filename, 0, 5) == 'sess_')
                  {
                        $data = file_get_contents("$path/$filename");
                        if (!empty($data))
                                {
                                  session_decode($data);
                                  $session = $_SESSION;
                                  $_SESSION = array();
                                  echo("<pre>");
                                  echo "Session [" .
substr($filename, 5) . "]\n";
                                  print_r($session);
                                  echo "\n--\n\n";
                                  echo("</pre>");
                                }
                  }
        }
Goes through 'session.save_path' and looks for session files. If it finds one, it opens it and prints it out. Could be quit dangerous on a shared host, yes. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#235686) next »