eZPublish  3.9
ezsession.php File Reference


 eZRegisterSessionFunctions ()
 eZSessionClose ()
 eZSessionCountActive ()
 eZSessionDestroy ($key)
 eZSessionEmpty ()
 eZSessionGarbageCollector ()
 eZSessionOpen ()
eZSessionRead ($key)
 eZSessionRegenerate ()
 eZSessionRemove ()
 eZSessionSetUserID ($userID)
 eZSessionStart ()
 eZSessionStop ()
 eZSessionUserID ()
 eZSessionWrite ($key, $value)

Function Documentation

eZRegisterSessionFunctions ( )

Register the needed session functions. Call this only once.

Referenced by eZSessionStart().

eZSessionClose ( )
eZSessionCountActive ( )

Counts the number of active session and returns it.

eZSessionDestroy (   $key)

Will remove a session from the database.

eZSessionEmpty ( )

Removes all entries from session.

eZSessionGarbageCollector ( )

Handles session cleanup. Will delete timed out sessions from the database.

eZSessionOpen ( )

Re-implementation of PHP session management using database.

The session system has a hook system which allows external code to perform extra tasks before and after a certain action is executed. For instance to cleanup a table when sessions are removed. To create a hook function the global variable eZSessionFunctions must be filled in. This contains an associative array with hook points, e.g. destroy_pre which is checked by the session system. Each hook point must contain an array with function names to execute, if the hook point does not exist the session handler will not handle the hooks.

function cleanupStuff( &$db, $key, $escKey )
// Do cleanup here
if ( !isset( $GLOBALS['eZSessionFunctions']['destroy_pre'] ) )
$GLOBALS['eZSessionFunctions']['destroy_pre'] = array();
$GLOBALS['eZSessionFunctions']['destroy_pre'][] = 'cleanupstuff';

When new data is inserted to the database it will call the update_pre and update_post hooks. The signature of the function is function insert( &$db, $key, $escapedKey, $expirationTime, $userID, $value )

When existing data is updated in the databbase it will call the insert_pre and insert_post hook. The signature of the function is function update( &$db, $key, $escapedKey, $expirationTime, $userID, $value )

When a specific session is destroyed in the database it will call the destroy_pre and destroy_post hooks. The signature of the function is function destroy( &$db, $key, $escapedKey )

When multiple sessions are expired (garbage collector) in the database it will call the gc_pre and gc_post hooks. The signature of the function is function gcollect( &$db, $expiredTime )

When all sessionss are removed from the database it will call the empty_pre and empty_post hooks. The signature of the function is function empty( &$db )

$dbThe database object used by the session manager.
$keyThe session key which are being worked on, see also $escapedKey
$escapedKeyThe same key as $key but is escaped correctly for the database. Use this to save a call to eZDBInterface::escapeString()
$expirationTimeAn integer specifying the timestamp of when the session will expire.
$expiredTimeSimilar to $expirationTime but is the time used to figure if a session is expired in the database. ie. all sessions with lower expiration times will be removed.
& eZSessionRead (   $key)
eZSessionRegenerate ( )

Will make sure the user gets a new session ID while keepin the session data. This is useful to call on logins, to avoid sessions theft from users.

This requires PHP 4.3.2 and higher which has the session_regenerate_id
true if succesful

Referenced by eZUser\setCurrentlyLoggedInUser().

eZSessionRemove ( )

Removes the current session and resets session variables.

Referenced by eZScript\shutdown().

eZSessionSetUserID (   $userID)

Sets the current user ID to $userID, this ID will be written to the session table field user_id when the page is done.

See Also

Referenced by eZUser\instance(), eZUser\logoutCurrent(), and eZUser\setCurrentlyLoggedInUser().

eZSessionStart ( )

Makes sure that the session is started properly. Multiple calls will just be ignored.

Referenced by eZScript\initialize(), and eZHTTPTool\instance().

eZSessionStop ( )

Makes sure session data is stored in the session and stops the session.

eZSessionUserID ( )

Returns the current session ID. The session handler will not care about value of the ID, it's entirely up to the clients of the session handler to use and update this value.

eZSessionWrite (   $key,

Will write the session information to database.