Support Joomla!

Packages

Package: Joomla-Framework

License

Content on this site is copyright © 2005 - 2008 Open Source Matters Inc and can be used in accordance with the Joomla! Electronic Documentation License. Some parts of this website may be subject to other licenses.
Source code for file /joomla/session/storage/database.php

Documentation is available at database.php

  1. <?php
  2. /**
  3. @version        $Id:database.php 6961 2007-03-15 16:06:53Z tcp $
  4. @package        Joomla.Framework
  5. @subpackage    Session
  6. @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
  7. @license        GNU/GPL, see LICENSE.php
  8. *  Joomla! is free software. This version may have been modified pursuant
  9. *  to the GNU General Public License, and as distributed it includes or
  10. *  is derivative of works licensed under the GNU General Public License or
  11. *  other free or open source software licenses.
  12. *  See COPYRIGHT.php for copyright notices and details.
  13. */
  14.  
  15. // Check to ensure this file is within the rest of the framework
  16. defined('JPATH_BASE'or die();
  17.  
  18. /**
  19. * Database session storage handler for PHP
  20. *
  21. @package        Joomla.Framework
  22. @subpackage    Session
  23. @since        1.5
  24. @see http://www.php.net/manual/en/function.session-set-save-handler.php
  25. */
  26. {
  27.     var $_data = null;
  28.  
  29.     /**
  30.      * Open the SessionHandler backend.
  31.      *
  32.      * @access public
  33.      * @param string $save_path     The path to the session object.
  34.      * @param string $session_name  The name of the session.
  35.      * @return boolean  True on success, false otherwise.
  36.      */
  37.     function open($save_path$session_name)
  38.     {
  39.         return true;
  40.     }
  41.  
  42.     /**
  43.      * Close the SessionHandler backend.
  44.      *
  45.      * @access public
  46.      * @return boolean  True on success, false otherwise.
  47.      */
  48.     function close()
  49.     {
  50.         return true;
  51.     }
  52.  
  53.      /**
  54.       * Read the data for a particular session identifier from the
  55.       * SessionHandler backend.
  56.       *
  57.       * @access public
  58.       * @param string $id  The session identifier.
  59.       * @return string  The session data.
  60.       */
  61.     function read($id)
  62.     {
  63.         $db =JFactory::getDBO();
  64.         if(!$db->connected()) {
  65.             return false;
  66.         }
  67.  
  68.         $session JTable::getInstance('session');
  69.         $session->load($id);
  70.         return (string)$session->data;
  71.     }
  72.  
  73.     /**
  74.      * Write session data to the SessionHandler backend.
  75.      *
  76.      * @access public
  77.      * @param string $id            The session identifier.
  78.      * @param string $session_data  The session data.
  79.      * @return boolean  True on success, false otherwise.
  80.      */
  81.     function write($id$session_data)
  82.     {
  83.         $db =JFactory::getDBO();
  84.         if(!$db->connected()) {
  85.             return false;
  86.         }
  87.  
  88.         $session JTable::getInstance('session');
  89.         $session->load($id);
  90.         $session->data $session_data;
  91.         $session->store();
  92.  
  93.         return true;
  94.     }
  95.  
  96.     /**
  97.       * Destroy the data for a particular session identifier in the
  98.       * SessionHandler backend.
  99.       *
  100.       * @access public
  101.       * @param string $id  The session identifier.
  102.       * @return boolean  True on success, false otherwise.
  103.       */
  104.     function destroy($id)
  105.     {
  106.         $db =JFactory::getDBO();
  107.         if(!$db->connected()) {
  108.             return false;
  109.         }
  110.  
  111.         $session JTable::getInstance('session');
  112.         $session->delete($id);
  113.         return true;
  114.     }
  115.  
  116.     /**
  117.      * Garbage collect stale sessions from the SessionHandler backend.
  118.      *
  119.      * @access public
  120.      * @param integer $maxlifetime  The maximum age of a session.
  121.      * @return boolean  True on success, false otherwise.
  122.      */
  123.     function gc($maxlifetime)
  124.     {
  125.         $db =JFactory::getDBO();
  126.         if(!$db->connected()) {
  127.             return false;
  128.         }
  129.  
  130.         $session JTable::getInstance('session');
  131.         $session->purge($maxlifetime);
  132.         return true;
  133.     }
  134. }

Documentation generated on Sat, 14 Nov 2009 11:12:00 +0000 by phpDocumentor 1.3.1