| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
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 - 2010 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 class JSessionStorageDatabase extends JSessionStorage 27 { 28 var $_data = null; 29 30 /** 31 * Open the SessionHandler backend. 32 * 33 * @access public 34 * @param string $save_path The path to the session object. 35 * @param string $session_name The name of the session. 36 * @return boolean True on success, false otherwise. 37 */ 38 function open($save_path, $session_name) 39 { 40 return true; 41 } 42 43 /** 44 * Close the SessionHandler backend. 45 * 46 * @access public 47 * @return boolean True on success, false otherwise. 48 */ 49 function close() 50 { 51 return true; 52 } 53 54 /** 55 * Read the data for a particular session identifier from the 56 * SessionHandler backend. 57 * 58 * @access public 59 * @param string $id The session identifier. 60 * @return string The session data. 61 */ 62 function read($id) 63 { 64 $db =& JFactory::getDBO(); 65 if(!$db->connected()) { 66 return false; 67 } 68 69 $session = & JTable::getInstance('session'); 70 $session->load($id); 71 return (string)$session->data; 72 } 73 74 /** 75 * Write session data to the SessionHandler backend. 76 * 77 * @access public 78 * @param string $id The session identifier. 79 * @param string $session_data The session data. 80 * @return boolean True on success, false otherwise. 81 */ 82 function write($id, $session_data) 83 { 84 $db =& JFactory::getDBO(); 85 if(!$db->connected()) { 86 return false; 87 } 88 89 $session = & JTable::getInstance('session'); 90 if ($session->load($id)) { 91 $session->data = $session_data; 92 $session->store(); 93 } else { 94 // if load failed then we assume that it is because 95 // the session doesn't exist in the database 96 // therefore we use insert instead of store 97 $app = &JFactory::getApplication(); 98 $session->data = $session_data; 99 $session->insert($id, $app->getClientId()); 100 } 101 102 return true; 103 } 104 105 /** 106 * Destroy the data for a particular session identifier in the 107 * SessionHandler backend. 108 * 109 * @access public 110 * @param string $id The session identifier. 111 * @return boolean True on success, false otherwise. 112 */ 113 function destroy($id) 114 { 115 $db =& JFactory::getDBO(); 116 if(!$db->connected()) { 117 return false; 118 } 119 120 $session = & JTable::getInstance('session'); 121 $session->delete($id); 122 return true; 123 } 124 125 /** 126 * Garbage collect stale sessions from the SessionHandler backend. 127 * 128 * @access public 129 * @param integer $maxlifetime The maximum age of a session. 130 * @return boolean True on success, false otherwise. 131 */ 132 function gc($maxlifetime) 133 { 134 $db =& JFactory::getDBO(); 135 if(!$db->connected()) { 136 return false; 137 } 138 139 $session = & JTable::getInstance('session'); 140 $session->purge($maxlifetime); 141 return true; 142 } 143 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |