Source code for file /joomla/database/table/session.php
Documentation is available at session.php
* @version $Id: session.php 6543 2007-02-09 14:03:09Z pasamio $
* @package Joomla.Framework
* @copyright Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
// Check to ensure this file is within the rest of the framework
* @package Joomla.Framework
* @param database A database connector object
parent::__construct( '#__session', 'session_id', $db );
function insert($sessionId, $clientId)
$ret =
$this->_db->insertObject( $this->_tbl, $this, 'session_id' );
function update( $updateNulls =
false )
$ret =
$this->_db->updateObject( $this->_tbl, $this, 'session_id', $updateNulls );
* Destroys the pesisting session
$query =
'DELETE FROM #__session'
.
' WHERE session_id = '.
$this->_db->Quote( $sessionId );
$this->_db->setQuery( $query );
if ( !$this->_db->query() ) {
* @param int Session age in seconds
* @return mixed Resource on success, null on fail
function purge( $maxLifetime =
1440 )
$past =
time() -
$maxLifetime;
$query =
'DELETE FROM '.
$this->_tbl .
' WHERE ( time < '.
$past .
' )';
$this->_db->setQuery($query);
return $this->_db->query();
* Find out if a user has a one or more active sessions
* @param int $userid The identifier of the user
* @return boolean True if a session for this user exists
$query =
'SELECT COUNT(userid) FROM #__session'
.
' WHERE userid = '.
$this->_db->Quote( $userid );
$this->_db->setQuery( $query );
if ( !$result =
$this->_db->loadResult() ) {
return (boolean)
$result;