Session object.

package XenForo_Core

 Methods

Constructor.

__construct(array $config, \Zend_Cache_Core $cache, \Zend_Db_Adapter_Abstract $db) 

Parameters

$config

array

Config elements to override default.

$cache

\Zend_Cache_Corenull

$db

\Zend_Db_Adapter_Abstractnull

Changes the user ID of the session and automatically regenerates it to prevent session hijacking.

changeUserId(integer $userId, boolean $keepExisting) 

Parameters

$userId

integer

$keepExisting

boolean

If true, keeps existing session info; usually want this to be false to ensure things are built as needed

Deletes the current session.

delete() 

The session cookie will be removed as well.

Deletes all sessions that have expired.

deleteExpiredSessions() 

Deletes the specified session from the source.

deleteSessionFromSource(string $sessionId) 

Parameters

$sessionId

string

Gets the specified data from the session.

get(string $key) : mixed

Parameters

$key

string

Returns

mixed

Gets all data from the session.

getAll() : array

Returns

array

This simply gets public session, from cookies if necessary.

getPublicSession(\Zend_Controller_Request_Http $request) : \XenForo_Session
Static

Parameters

$request

\Zend_Controller_Request_Http

Returns

Gets the specified session data from the source.

getSessionFromSource(string $sessionId) : array | false

Parameters

$sessionId

string

Returns

arrayfalse

Gets the session ID.

getSessionId() : string

Returns

string

Checks whether or not the specified key exists in the session data.

isRegistered(string $key) : boolean

Parameters

$key

string

Returns

boolean

Checks whether or not the user agent is a known robot.

isRobot(string $userAgent) : string | boolean
Static

Parameters

$userAgent

string

Returns

stringboolean

Checks whether or not the referer is a search engine.

isSearchReferer(string $referer) : string | boolean
Static

Parameters

$referer

string

Returns

stringboolean

Maintains the current session values (if desired), but changes the session ID.

regenerate(boolean $keepExisting) 

Use this when the context (eg, user ID) of a session changes.

Parameters

$keepExisting

boolean

If true, keeps the existing info; if false, session data is removed

Removes the specified data from the session.

remove(string $key) 

Parameters

$key

string

Saves the current session.

save() 

If a session is being created, the session cookie will be created.

saveSessionToSource()

saveSessionToSource($sessionId, $isUpdate) 

Parameters

$sessionId

$isUpdate

True if the session has been saved in this request (and thus write locked).

saved() : boolean

Returns

boolean

True if the session exists (existed in previous request or has been saved).

sessionExists() : boolean

Returns

boolean

Determines if the existing session matches the given IP address.

sessionMatchesIp(array $session, integer | false $ipAddress) : boolean

Looks for the session's IP in the ip key. If not found or not an int, check passes.

Parameters

$session

array

$ipAddress

integerfalse

IPv4 address as int or false to prevent IP check

Returns

boolean

Sets the specified data into the session.

set(string $key, mixed $value) 

Can't be called after saving.

Parameters

$key

string

$value

mixed

Starts the session running.

start(string | null $sessionId, string | null $ipAddress) 

Parameters

$sessionId

stringnull

Session ID. If not provided, read from cookie.

$ipAddress

stringnull

IPv4 address in string format, for limiting access. If null, grabbed automatically.

Starts the admin session and sets up the visitor.

startAdminSession(\Zend_Controller_Request_Http $request) : \XenForo_Session
Static

Parameters

$request

\Zend_Controller_Request_Httpnull

Returns

Starts running the public session handler.

startPublicSession(\Zend_Controller_Request_Http $request) : \XenForo_Session
Static

This will automatically log in the user via cookies if needed, and setup the visitor object. The session will be registered in the registry.

Parameters

$request

\Zend_Controller_Request_Httpnull

Returns

_getSessionCacheName()

_getSessionCacheName($sessionId) 

Parameters

$sessionId

Sets up the session.

_setup(string $sessionId, integer | false $ipAddress, array $defaultSession) 

Parameters

$sessionId

string

Session ID to look up, if one exists

$ipAddress

integerfalse

IPv4 address in int format (ip2long), for access limiting.

$defaultSession

arraynull

If no session can be found, uses this as the default session value

 Properties

 

$knownRobots : array
 

$searchDomains : array
 

$_cache : \Zend_Cache_Core

If specified, the session will be stored here instead of the DB.

 

$_config : array

See constructor.

 

$_dataChanged : boolean
 

$_db : \Zend_Db_Adapter_Abstract

If no cache is specified, the session will be stored in the DB.

 

$_saved : boolean
 

$_session : string
 

$_sessionExists : boolean

Becomes true after a session is saved.

 

$_sessionId : string

An md5 hash.