.

XCacheSession Class Reference
[XCache]

Redirect session to write to XCache. More...

Inheritance diagram for XCacheSession:
ISessionHandler

List of all members.

Public Member Functions

  close ()
  Close a session.
  destroy ($key)
  Delete a session.
  gc ($lifetime)
  Delete outdated sessions.
  open ($save_path, $session_name)
  Open a session.
  read ($key)
  Load session data from xcache.
  write ($key, $value)
  Write session data to XCache.

Protected Member Functions

  create_key ($key)

Detailed Description

Redirect session to write to XCache.

Author:
Gerd Riesselmann

Definition at line 8 of file session.xcache.impl.php.


Member Function Documentation

XCacheSession::close (  ) 

Close a session.

Implements ISessionHandler.

Definition at line 19 of file session.xcache.impl.php.

00019                                 {
00020                 //Note that for security reasons the Debian and Ubuntu distributions of 
00021                 //php do not call _gc to remove old sessions, but instead run /etc/cron.d/php*, 
00022                 //which check the value of session.gc_maxlifetime in php.ini and delete the session 
00023                 //files in /var/lib/php*.  This is all fine, but it means if you write your own 
00024                 //session handlers you'll need to explicitly call your _gc function yourself.  
00025                 //A good place to do this is in your _close function
00026                 
00027                 // Since XCache takes care of life time, no gc is needed
00028                 //$this->gc(ini_get('session.gc_maxlifetime'));
00029                 return true;
00030         }
XCacheSession::create_key ( key  )  [protected]

Definition at line 75 of file session.xcache.impl.php.

00075                                             {
00076                 return 'g$s' . Config::get_url(Config::URL_DOMAIN) . '_' . $key;
00077         } 
XCacheSession::destroy ( key  ) 

Delete a session.

Implements ISessionHandler.

Definition at line 63 of file session.xcache.impl.php.

00063                                       {
00064                 xcache_unset($this->create_key($key));
00065         }
XCacheSession::gc ( lifetime  ) 

Delete outdated sessions.

Implements ISessionHandler.

Definition at line 70 of file session.xcache.impl.php.

00070                                       {
00071                 // XCache does this for us
00072                 return true;
00073         }
XCacheSession::open ( save_path,
session_name  
)

Open a session.

Implements ISessionHandler.

Definition at line 12 of file session.xcache.impl.php.

00012                                                         {
00013                 return true;
00014         }
XCacheSession::read ( key  ) 

Load session data from xcache.

Implements ISessionHandler.

Definition at line 35 of file session.xcache.impl.php.

00035                                    {
00036                 // Write and Close handlers are called after destructing objects since PHP 5.0.5
00037                 // Thus destructors can use sessions but session handler can't use objects.
00038                 // So we are moving session closure before destructing objects.
00039                 register_shutdown_function('session_write_close');
00040                 $key = $this->create_key($key);
00041                 if (xcache_isset($key)) {
00042                         return xcache_get($key);
00043                 }
00044                 return '';
00045         }
XCacheSession::write ( key,
value  
)

Write session data to XCache.

Implements ISessionHandler.

Definition at line 50 of file session.xcache.impl.php.

00050                                             {
00051                 try {
00052                         xcache_set($this->create_key($key), $value, ini_get('session.gc_maxlifetime'));
00053                         return true;
00054                 }
00055                 catch(Exception $ex) {
00056                         return false;
00057                 }       
00058         }

The documentation for this class was generated from the following file: