1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
<?php
/**
* SessionHandler implementation for PHP's built-in session handler.
*
* Required parameters:<pre>
* None.</pre>
*
* Optional parameters:<pre>
* None.</pre>
*
* $Horde: framework/SessionHandler/SessionHandler/none.php,v 1.3.2.4 2006/01/01 21:28:34 jan Exp $
*
* Copyright 2005-2006 Matt Selsky <selsky@columbia.edu>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Matt Selsky <selsky@columbia.edu>
* @since Horde 3.1
* @package Horde_SessionHandler
*/
class SessionHandler_none extends SessionHandler {
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
*
* @return string The session data.
*/
function read($id)
{
$file = session_save_path() . DIRECTORY_SEPARATOR . 'sess_' . $id;
$session_data = @file_get_contents($file);
if ($session_data === false) {
return PEAR::raiseError(_("Unable to read file: ") . $file);
}
return $session_data;
}
/**
* Get a list of the valid session identifiers.
*
* @return array A list of valid session identifiers.
*/
function getSessionIDs()
{
$sessions = array();
$path = session_save_path();
$d = dir(empty($path) ? Util::getTempDir() : $path);
while (false !== ($entry = $d->read())) {
/* Make sure we're dealing with files that start with
* sess_. */
if (is_file($d->path . DIRECTORY_SEPARATOR . $entry) &&
!strncmp($entry, 'sess_', strlen('sess_'))) {
$sessions[] = substr($entry, strlen('sess_'));
}
}
return $sessions;
}
}
|