Overview

Packages

  • SessionHandler

Classes

  • Horde_SessionHandler
  • Horde_SessionHandler_Exception
  • Horde_SessionHandler_Storage
  • Horde_SessionHandler_Storage_Builtin
  • Horde_SessionHandler_Storage_External
  • Horde_SessionHandler_Storage_File
  • Horde_SessionHandler_Storage_Memcache
  • Horde_SessionHandler_Storage_Sql
  • Horde_SessionHandler_Storage_Stack
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * SessionHandler storage implementation for PHP's built-in session handler.
  4:  * This doesn't do any session handling itself - instead, it exists to allow
  5:  * utility features to be used with the built-in PHP handler.
  6:  *
  7:  * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
  8:  *
  9:  * See the enclosed file COPYING for license information (LGPL). If you
 10:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 11:  *
 12:  * @author   Matt Selsky <selsky@columbia.edu>
 13:  * @category Horde
 14:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 15:  * @package  SessionHandler
 16:  */
 17: class Horde_SessionHandler_Storage_Builtin extends Horde_SessionHandler_Storage
 18: {
 19:     /**
 20:      * Directory with session files.
 21:      *
 22:      * @var string
 23:      */
 24:     protected $_path;
 25: 
 26:     /**
 27:      */
 28:     public function __construct(array $params = array())
 29:     {
 30:         parent::__construct($params);
 31: 
 32:         $this->_path = session_save_path();
 33:         if (!$this->_path) {
 34:             $this->_path = Horde_Util::getTempDir();
 35:         }
 36:     }
 37: 
 38:     /**
 39:      */
 40:     public function open($save_path = null, $session_name = null)
 41:     {
 42:     }
 43: 
 44:      /**
 45:       */
 46:     public function close()
 47:     {
 48:     }
 49: 
 50:     /**
 51:      */
 52:     public function read($id)
 53:     {
 54:         $file = $this->_path . '/sess_' . $id;
 55:         $session_data = @file_get_contents($file);
 56:         if (($session_data === false) && $this->_logger) {
 57:             $this->_logger->log('Unable to read file: ' . $file, 'ERR');
 58:         }
 59: 
 60:         return strval($session_data);
 61:     }
 62: 
 63:     /**
 64:      */
 65:     public function write($id, $session_data)
 66:     {
 67:         return false;
 68:     }
 69: 
 70:     /**
 71:      */
 72:     public function destroy($id)
 73:     {
 74:         return false;
 75:     }
 76: 
 77:     /**
 78:      */
 79:     public function gc($maxlifetime = 300)
 80:     {
 81:         return false;
 82:     }
 83: 
 84:     /**
 85:      */
 86:     public function getSessionIDs()
 87:     {
 88:         $sessions = array();
 89: 
 90:         try {
 91:             $di = new DirectoryIterator($this->_path);
 92:         } catch (UnexpectedValueException $e) {
 93:             return $sessions;
 94:         }
 95: 
 96:         foreach ($di as $val) {
 97:             /* Make sure we're dealing with files that start with sess_. */
 98:             if ($val->isFile() &&
 99:                 (strpos($val->getFilename(), 'sess_') === 0)) {
100:                 $sessions[] = substr($val->getFilename(), strlen('sess_'));
101:             }
102:         }
103: 
104:         return $sessions;
105:     }
106: 
107: }
108: 
API documentation generated by ApiGen