API16:JSessionStorageDatabase/gc
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Garbage collect stale sessions from the SessionHandler backend.
Description:JSessionStorageDatabase/gc
Syntax
gc($lifetime=1440)
| Parameter Name | Default Value | Description |
|---|---|---|
| $lifetime | 1440 | The maximum age of a session. |
Returns
boolean True on success, false otherwise.
Defined in
libraries/joomla/session/storage/database.php
Importing
jimport( 'joomla.session.storage.database' );
Source Body
function gc($lifetime = 1440) { // Get the database connection object and verify its connected. $db = &JFactory::getDbo(); if (!$db->connected()) { return false; } // Determine the timestamp threshold with which to purge old sessions. $past = time() - $lifetime; // Remove expired sessions from the database. $db->setQuery( 'DELETE FROM `#__session`' . ' WHERE `time` < '.(int) $past ); return (boolean) $db->query(); }
[Edit See Also] SeeAlso:JSessionStorageDatabase/gc
Examples
<CodeExamplesForm />
