eZPublishCommunityProject(LegacyStack)  2013.5
eZSession Class Reference

Static Public Member Functions

static addCallback ($type, $callback)
 Adds a callback function, to be triggered by eZSession::triggerCallback() when a certain session event occurs. More...
 
static cleanup ()
 Truncates all session data in the database, this function is not supported by session handlers that don't have a session backend on their own. More...
 
static countActive ()
 Counts the number of active session and returns it, this function is not supported by session handlers that don't have a session backend on their own. More...
 
static garbageCollector ()
 Deletes all expired session data in the database, this function is not supported by session handlers that don't have a session backend on their own. More...
 
static & get ($key=null, $defaultValue=null)
 Get session value (wrapper) More...
 
static getHandlerInstance (ezpSessionHandler $handler=null)
 Get curren session handler. More...
 
static hasStarted ()
 Return value to indicate if session has started or not. More...
 
static init ($name, $started, $ns, ezpSessionHandler $handler)
 Initializes the legacy session system with injected settings. More...
 
static issetkey ($key, $forceStart=true)
 Isset session value (wrapper) More...
 
static lazyStart ($startIfUserHasCookie=true)
 Inits eZSession and starts it if user has cookie and $startIfUserHasCookie is true. More...
 
static regenerate ($updateBackendData=true)
 Will make sure the user gets a new session ID while keepin the session data. More...
 
static remove ()
 Removes the current session and resets session variables. More...
 
static set ($key, $value)
 Set session value (wrapper) More...
 
static setCookieLifetime ($lifetime)
 Set the Cookie timeout of session cookie. More...
 
static setCookieParams ($lifetime=false)
 Set default cookie parameters based on site.ini settings (fallback to php.ini settings) Used by eZSession::registerFunctions(). More...
 
static setUserID ($userID)
 Sets the current userID used by ezpSessionHandlerDB::write() on shutdown. More...
 
static start ($cookieTimeout=false)
 Starts the session and sets the timeout of the session cookie. More...
 
static stop ()
 Writes session data and stops the session, if not already stopped. More...
 
static triggerCallback ($type, $params)
 Triggers callback functions by type, registrated by eZSession::addCallback() Use: eZSession::triggerCallback('gc_pre', array( $db, $time ) );. More...
 
static unsetkey ($key, $forceStart=true)
 unset session value (wrapper) More...
 
static userHasSessionCookie ()
 Returns if user had session cookie at start of request or not. More...
 
static userID ()
 Gets the current user id. More...
 

Protected Member Functions

 __construct ()
 Constructor (not used, this is an all static class) More...
 

Static Protected Member Functions

static forceStart ()
 See eZSession::start(). More...
 
static registerFunctions ($sessionName=false, ezpSessionHandler $handler=null)
 Register the needed session functions, this is called automatically by eZSession::start(), so only call this if you don't start the session. More...
 

Static Protected Attributes

static $callbackFunctions = array()
 
static $handlerInstance = null
 
static $hasSessionCookie = null
 
static $hasStarted = false
 
static $namespace = null
 
static $userID = 0
 

Static Private Member Functions

static & sessionArray ()
 Returns the session array to use taking into account the namespace that might have been injected. More...
 

Constructor & Destructor Documentation

eZSession::__construct ( )
protected

Constructor (not used, this is an all static class)

Member Function Documentation

static eZSession::addCallback (   $type,
  $callback 
)
static

Adds a callback function, to be triggered by eZSession::triggerCallback() when a certain session event occurs.

Use: eZSession::addCallback('gc_pre', myCustomGarabageFunction );

Since
4.1
Deprecated:
since 4.5, use ezpEvent::getInstance()->attach() with new events
Parameters
string$typecleanup, gc, destroy, insert and update, pre and post types.
handler$callbacka function to call.

Referenced by ezpKernelWeb\requestInit().

static eZSession::cleanup ( )
static

Truncates all session data in the database, this function is not supported by session handlers that don't have a session backend on their own.

Since
4.1
Returns
bool
static eZSession::countActive ( )
static

Counts the number of active session and returns it, this function is not supported by session handlers that don't have a session backend on their own.

Since
4.1
Returns
string Number of sessions.
static eZSession::forceStart ( )
staticprotected

See eZSession::start().

See Also
ezpSessionHandler::sessionStart()
Since
4.4
Returns
true
static eZSession::garbageCollector ( )
static

Deletes all expired session data in the database, this function is not supported by session handlers that don't have a session backend on their own.

Since
4.1
Returns
bool
static& eZSession::get (   $key = null,
  $defaultValue = null 
)
static

Get session value (wrapper)

Since
4.4
Parameters
string | null$keyReturn the whole session array if null otherwise the value of $key
null | mixed$defaultValueReturn this if not null and session has not started
Returns
mixed|null $defaultValue if key does not exist, otherwise session value depending on $key

Referenced by eZHTTPTool\attribute(), and eZHTTPTool\sessionVariable().

static eZSession::getHandlerInstance ( ezpSessionHandler  $handler = null)
static

Get curren session handler.

Since
4.4
Returns
ezpSessionHandler

Referenced by eZUser\removeSessionData(), ezpKernelTreeMenu\sessionInit(), and ezpKernelWeb\sessionInit().

static eZSession::hasStarted ( )
static

Return value to indicate if session has started or not.

Since
4.4
Returns
bool

Referenced by eZUser\instance(), eZUserLoginHandler\preCheck(), and ezpKernelWeb\run().

static eZSession::init (   $name,
  $started,
  $ns,
ezpSessionHandler  $handler 
)
static

Initializes the legacy session system with injected settings.

This is method is to be used when Symfony2 "drives" the session, it replaces start/lazyStart in such case.

Parameters
string$nameName of the session
bool$startedWhether the session is already started or not
string$nsNamespace ie the key under which session data should be put in global array

Referenced by ezpKernelTreeMenu\sessionInit(), and ezpKernelWeb\sessionInit().

static eZSession::issetkey (   $key,
  $forceStart = true 
)
static

Isset session value (wrapper)

Since
4.4
Parameters
string$key
bool$forceStartForce session start if true
Returns
bool|null Null if session has not started and $forceStart is false

Referenced by eZUser\checkUser(), and eZHTTPTool\hasSessionVariable().

static eZSession::lazyStart (   $startIfUserHasCookie = true)
static

Inits eZSession and starts it if user has cookie and $startIfUserHasCookie is true.

Since
4.4
Parameters
bool$startIfUserHasCookie
Returns
bool|null

Referenced by ezpKernelTreeMenu\sessionInit(), and ezpKernelWeb\sessionInit().

static eZSession::regenerate (   $updateBackendData = true)
static

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. NOTE: make sure you set new user id first using eZSession::setUserID()

Since
4.1
Parameters
bool$updateBackendDataset to false to not update session backend with new session id and user id.
Returns
bool Depending on if session was regenerated.

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

static eZSession::registerFunctions (   $sessionName = false,
ezpSessionHandler  $handler = null 
)
staticprotected

Register the needed session functions, this is called automatically by eZSession::start(), so only call this if you don't start the session.

Since
4.1
Returns
bool Depending on if eZSession is registrated as session handler.
static eZSession::remove ( )
static

Removes the current session and resets session variables.

Note: implicit stops session as well!

Since
4.1
Returns
bool Depending on if session was removed.

Referenced by eZScript\shutdown().

static& eZSession::sessionArray ( )
staticprivate

Returns the session array to use taking into account the namespace that might have been injected.

Since
5.0
Returns
byRef session array to use
static eZSession::set (   $key,
  $value 
)
static

Set session value (wrapper)

Since
4.4
Parameters
string$key
Returns
bool

Referenced by eZUser\setCurrentlyLoggedInUser(), and eZHTTPTool\setSessionVariable().

static eZSession::setCookieLifetime (   $lifetime)
static

Set the Cookie timeout of session cookie.

Since
5.0
Parameters
int$lifetimeCookie timeout of the session cookie
static eZSession::setCookieParams (   $lifetime = false)
static

Set default cookie parameters based on site.ini settings (fallback to php.ini settings) Used by eZSession::registerFunctions().

If you only want to set the cookie lifetime, use eZSession::setCookieLifetime instead. Note: this will only have affect when session is created / re-created

Since
4.4
Parameters
int | false$lifetimeCookie timeout of session cookie, will read from ini if not set
static eZSession::setUserID (   $userID)
static

Sets the current userID used by ezpSessionHandlerDB::write() on shutdown.

Since
4.1
Parameters
int$userIDto use in ezpSessionHandlerDB::write()

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

static eZSession::start (   $cookieTimeout = false)
static

Starts the session and sets the timeout of the session cookie.

Multiple calls will be ignored unless you call eZSession::stop() first.

Since
4.1
Parameters
int | false$cookieTimeoutUse this to set custom cookie timeout.
Returns
bool Depending on if session was started.

Referenced by eZScript\initialize(), ezpKernelTreeMenu\sessionInit(), and ezpKernelWeb\sessionInit().

static eZSession::stop ( )
static

Writes session data and stops the session, if not already stopped.

Since
4.1
Returns
bool Depending on if session was stopped.

Referenced by eZFile\download(), and eZFilePassthroughHandler\handleFileDownload().

static eZSession::triggerCallback (   $type,
  $params 
)
static

Triggers callback functions by type, registrated by eZSession::addCallback() Use: eZSession::triggerCallback('gc_pre', array( $db, $time ) );.

Since
4.1
Deprecated:
since 4.5, use ezpEvent::getInstance()->notify() with new events
Parameters
string$typecleanup, gc, destroy, insert and update, pre and post types.
array$paramslist of parameters to pass to the callback function.
Returns
bool

Referenced by ezpSessionHandlerPHP\cleanup(), ezpSessionHandlerDB\cleanup(), ezpSessionHandlerDB\destroy(), ezpSessionHandlerSymfony\gc(), ezpSessionHandlerPHP\gc(), ezpSessionHandlerDB\gc(), ezpSessionHandlerSymfony\regenerate(), ezpSessionHandlerPHP\regenerate(), and ezpSessionHandlerDB\regenerate().

static eZSession::unsetkey (   $key,
  $forceStart = true 
)
static

unset session value (wrapper)

Since
4.4
Parameters
string$key
bool$forceStartForce session start if true
Returns
bool|null True if value was removed, false if it did not exist and null if session is not started and $forceStart is false

Referenced by eZHTTPTool\removeSessionVariable().

static eZSession::userHasSessionCookie ( )
static

Returns if user had session cookie at start of request or not.

Since
4.1
Returns
bool|null Null if session is not started yet.
static eZSession::userID ( )
static

Member Data Documentation

eZSession::$callbackFunctions = array()
staticprotected
eZSession::$handlerInstance = null
staticprotected
eZSession::$hasSessionCookie = null
staticprotected
eZSession::$hasStarted = false
staticprotected
eZSession::$namespace = null
staticprotected
eZSession::$userID = 0
staticprotected

Referenced by setUserID().


The documentation for this class was generated from the following file: