vB_Session
in package
Uses
vB_Trait_NoSerialize
Class to handle sessions
Creates, updates, and validates sessions; retrieves user info of browsing user
Tags
Table of Contents
- $created : bool
- Whether the session was created or existed previously
- $changes : array<string|int, mixed>
- An array of changes. Used to prevent superfluous updates from being made.
- $config : array<string|int, mixed>
- $cookietimeout : mixed
- $cpsessionHash : string
- cpsessionhash is a special session hash for admins and moderators
- $data : mixed
- $datastore : vB_Datastore
- $db_fields : array<string|int, mixed>
- A list of variables in the $vars member that are in the database. Includes their types.
- $dBAssertor : vB_dB_Assertor
- $rememberMeToken : mixed
- $sessionIdHash : mixed
- $userinfo : array<string|int, mixed>
- Information about the user that this session belongs to.
- $vars : array<string|int, mixed>
- The individual session variables. Equivalent to $session from the past.
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- clearChannelPerms() : mixed
- clearUserInfo() : mixed
- Clear user cached info. Primarily needed for cleaning cache in memory.
- delete() : mixed
- Deletes the session from the session store.
- doLastVisitUpdate() : array<string|int, mixed>
- Updates the last visit and last activity times for guests and registered users (differently).
- doRememberMe() : mixed
- fetch_sessionhash() : string
- Fetches a valid sessionhash value, not necessarily the one tied to this session.
- fetch_userinfo() : array<string|int, mixed>
- Returns appropriate user info for the owner of this session.
- fetch_userinfo_value() : mix
- Returns appropriate value from the user info array for the owner of this session.
- fetchCpsessionHash() : string
- Create new cpsession for the user and insert it into database or fetch current existing one
- finalize() : mixed
- get() : mixed
- Gets a session variable.
- getAllVars() : array<string|int, mixed>
- Returns an array with all session vars
- getChannelPerms() : mixed
- getNewSession() : vB_Session
- Returns a new session of the type specified by defined constants
- getRememberMeToken() : mixed
- getSessionIdHash() : string
- Returns the sessionIdHash
- isCreated() : bool
- Returns whether the session was created
- loadLanguage() : mixed
- Loads basic language information
- loadPhraseGroups() : mixed
- Called after setting phrasegroups, adds new phrases to userinfo
- save() : mixed
- Saves the session into the database by inserting it or updating an existing one.
- set() : mixed
- Sets a session variable and updates the change list.
- setChannelPerms() : mixed
- setCpsessionHash() : mixed
- setSessionVars() : mixed
- validateCpsession() : bool
- Validate cpsession
- __construct() : mixed
- Constructor. Attempts to grab a session that matches parameters, but will create one if it can't.
- createSessionIdHash() : mixed
- Sets the attribute sessionIdHash
- fetch_session() : array<string|int, mixed>
- Fetches a default session. Used when creating a new session.
- fetch_substr_ip() : string
- Returns the IP address with the specified number of octets removed
- fetchStoredSession() : mixed
- fetchUserForRemember() : array<string|int, mixed>
- Get the user info based on the useroptions
- loadExistingSession() : mixed
- loadUserInfo() : mixed
- Loads user info and stores it in session object property ($this->userinfo) for a given user regarding options being passed.
- rememberFacebook() : mixed
- Attempt to create a new session for the user from facebook
- rememberSession() : mixed
- Attempt to create a new session for the user without asking for a new login
Properties
$created
Whether the session was created or existed previously
public
bool
$created
= alse
$changes
An array of changes. Used to prevent superfluous updates from being made.
protected
array<string|int, mixed>
$changes
= array()
$config
protected
array<string|int, mixed>
$config
$cookietimeout
protected
mixed
$cookietimeout
$cpsessionHash
cpsessionhash is a special session hash for admins and moderators
protected
string
$cpsessionHash
= ''
$data
protected
mixed
$data
= array()
$datastore
protected
vB_Datastore
$datastore
=
ull
$db_fields
A list of variables in the $vars member that are in the database. Includes their types.
protected
array<string|int, mixed>
$db_fields
= array('sessionhash' => B_Cleaner::TYPE_STR, 'userid' => B_Cleaner::TYPE_INT, 'host' => B_Cleaner::TYPE_STR, 'idhash' => B_Cleaner::TYPE_STR, 'lastactivity' => B_Cleaner::TYPE_INT, 'location' => B_Cleaner::TYPE_STR, 'styleid' => B_Cleaner::TYPE_INT, 'languageid' => B_Cleaner::TYPE_INT, 'loggedin' => B_Cleaner::TYPE_INT, 'inforum' => B_Cleaner::TYPE_INT, 'inthread' => B_Cleaner::TYPE_INT, 'incalendar' => B_Cleaner::TYPE_INT, 'badlocation' => B_Cleaner::TYPE_INT, 'useragent' => B_Cleaner::TYPE_STR, 'bypass' => B_Cleaner::TYPE_INT, 'profileupdate' => B_Cleaner::TYPE_INT, 'apiclientid' => B_Cleaner::TYPE_INT, 'apiaccesstoken' => B_Cleaner::TYPE_STR, 'emailstamp' => B_Cleaner::TYPE_INT)
$dBAssertor
protected
vB_dB_Assertor
$dBAssertor
=
ull
$rememberMeToken
protected
mixed
$rememberMeToken
= ''
$sessionIdHash
protected
mixed
$sessionIdHash
=
ull
$userinfo
Information about the user that this session belongs to.
protected
array<string|int, mixed>
$userinfo
=
ull
$vars
The individual session variables. Equivalent to $session from the past.
protected
array<string|int, mixed>
$vars
= array()
Methods
__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —clearChannelPerms()
public
clearChannelPerms() : mixed
Return values
mixed —clearUserInfo()
Clear user cached info. Primarily needed for cleaning cache in memory.
public
clearUserInfo() : mixed
Return values
mixed —delete()
Deletes the session from the session store.
public
delete() : mixed
Deletes records matching the session's sessionhash. If there is an apiaccesstoken then sessions matching that are also deleted.
Will have no effect and no error if the session doesn't exist.
Sets the session to "not created", but does not otherwise affect the session object.
Return values
mixed —doLastVisitUpdate()
Updates the last visit and last activity times for guests and registered users (differently).
public
doLastVisitUpdate(mixed $lastvisit, mixed $lastactivity) : array<string|int, mixed>
Last visit is set to the last activity time (before it's updated) only when a certain time has lapsed. Last activity is always set to the specified time.
Parameters
- $lastvisit : mixed
- $lastactivity : mixed
Return values
array<string|int, mixed> —Updated values for setting cookies (guest only)
doRememberMe()
public
doRememberMe(mixed $restoreSessionInfo[, mixed $gotsession = true ]) : mixed
Parameters
- $restoreSessionInfo : mixed
- $gotsession : mixed = true
Return values
mixed —fetch_sessionhash()
Fetches a valid sessionhash value, not necessarily the one tied to this session.
public
fetch_sessionhash() : string
Return values
string —32-character sessionhash
fetch_userinfo()
Returns appropriate user info for the owner of this session.
public
fetch_userinfo() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of user information.
fetch_userinfo_value()
Returns appropriate value from the user info array for the owner of this session.
public
fetch_userinfo_value(mixed $value) : mix
Parameters
- $value : mixed
Return values
mix —value of user information.
fetchCpsessionHash()
Create new cpsession for the user and insert it into database or fetch current existing one
public
fetchCpsessionHash([bool $renew = false ]) : string
Parameters
- $renew : bool = false
-
Whether to renew cpsession hash (Create a new one and drop the old one)
Tags
Return values
string —The new cpsession hash
finalize()
public
finalize(mixed $styleid, mixed $languageid) : mixed
Parameters
- $styleid : mixed
- $languageid : mixed
Return values
mixed —get()
Gets a session variable.
public
get(mixed $key) : mixed
Parameters
- $key : mixed
Return values
mixed —- Value of the key, NULL if not found
getAllVars()
Returns an array with all session vars
public
getAllVars() : array<string|int, mixed>
Return values
array<string|int, mixed> —getChannelPerms()
public
getChannelPerms(mixed $key) : mixed
Parameters
- $key : mixed
Return values
mixed —getNewSession()
Returns a new session of the type specified by defined constants
public
static getNewSession(vB_dB_Assertor &$dBAssertor, vB_Datastore &$datastore, array<string|int, mixed> &$config[, string $sessionhash = '' ], int $userid[, string $password = '' ], int $styleid, int $languageid) : vB_Session
Parameters
- $dBAssertor : vB_dB_Assertor
- $datastore : vB_Datastore
- $config : array<string|int, mixed>
- $sessionhash : string = ''
- $userid : int
- $password : string = ''
- $styleid : int
- $languageid : int
Tags
Return values
vB_Session —getRememberMeToken()
public
getRememberMeToken() : mixed
Return values
mixed —getSessionIdHash()
Returns the sessionIdHash
public
getSessionIdHash() : string
Return values
string —isCreated()
Returns whether the session was created
public
isCreated() : bool
Return values
bool —loadLanguage()
Loads basic language information
public
loadLanguage() : mixed
Return values
mixed —loadPhraseGroups()
Called after setting phrasegroups, adds new phrases to userinfo
public
loadPhraseGroups() : mixed
Return values
mixed —save()
Saves the session into the database by inserting it or updating an existing one.
public
save() : mixed
Return values
mixed —set()
Sets a session variable and updates the change list.
public
set(mixed $key, mixed $value) : mixed
Parameters
- $key : mixed
- $value : mixed
Return values
mixed —setChannelPerms()
public
setChannelPerms(mixed $key, mixed $perms) : mixed
Parameters
- $key : mixed
- $perms : mixed
Return values
mixed —setCpsessionHash()
public
setCpsessionHash(mixed $cpsessionhash) : mixed
Parameters
- $cpsessionhash : mixed
Return values
mixed —setSessionVars()
public
setSessionVars(mixed $userId) : mixed
Parameters
- $userId : mixed
Return values
mixed —validateCpsession()
Validate cpsession
public
validateCpsession([bool $updatetimeout = true ]) : bool
Parameters
- $updatetimeout : bool = true
-
Whether to update the table to reset the timeout
Return values
bool —__construct()
Constructor. Attempts to grab a session that matches parameters, but will create one if it can't.
protected
__construct(vB_DB_Assertor &$dBAssertor, vB_Datastore &$datastore, array<string|int, mixed> &$config[, mixed $sessionhash = '' ][, array<string|int, mixed> $restoreSessionInfo = [] ], mixed $styleid, mixed $languageid[, mixed $deferRememberMe = false ]) : mixed
Parameters
- $dBAssertor : vB_DB_Assertor
- $datastore : vB_Datastore
- $config : array<string|int, mixed>
-
-- vBulletin config array
- $sessionhash : mixed = ''
- $restoreSessionInfo : array<string|int, mixed> = []
-
-- Information to handle "remember me" logic.
- remembermetoken -- Token value for "remember me". Stored in the "password" cookie for legacy reasons. There are so special values to indicate that we should reauthentic via a method other than the internal vB remember me system.
- userid -- user we are remembering
- fbsr_{appid} (optional) -- Only valid if facebook is enabled, and only used if "remembermetoken" is "facebook".
- $styleid : mixed
- $languageid : mixed
- $deferRememberMe : mixed = false
Return values
mixed —createSessionIdHash()
Sets the attribute sessionIdHash
protected
createSessionIdHash() : mixed
Return values
mixed —fetch_session()
Fetches a default session. Used when creating a new session.
protected
fetch_session(mixed $userid) : array<string|int, mixed>
Parameters
- $userid : mixed
Return values
array<string|int, mixed> —Array of session variables
fetch_substr_ip()
Returns the IP address with the specified number of octets removed
protected
fetch_substr_ip(mixed $ip) : string
Parameters
- $ip : mixed
Return values
string —truncated IP address
fetchStoredSession()
protected
fetchStoredSession(mixed $sessionhash[, mixed $restoreSessionInfo = array() ]) : mixed
Parameters
- $sessionhash : mixed
- $restoreSessionInfo : mixed = array()
Return values
mixed —fetchUserForRemember()
Get the user info based on the useroptions
protected
fetchUserForRemember(mixed $userid, mixed $useroptions) : array<string|int, mixed>
Parameters
- $userid : mixed
- $useroptions : mixed
Return values
array<string|int, mixed> —user info array
loadExistingSession()
protected
loadExistingSession(mixed $sessionhash, mixed $restoreSessionInfo[, mixed $deferRememberMe = false ]) : mixed
Parameters
- $sessionhash : mixed
- $restoreSessionInfo : mixed
- $deferRememberMe : mixed = false
Return values
mixed —loadUserInfo()
Loads user info and stores it in session object property ($this->userinfo) for a given user regarding options being passed.
protected
loadUserInfo([mixed $nocache = false ]) : mixed
@param Int Userid to load info
Parameters
- $nocache : mixed = false
Return values
mixed —rememberFacebook()
Attempt to create a new session for the user from facebook
protected
rememberFacebook(array<string|int, mixed> $restoreSessionInfo, mixed $useroptions) : mixed
This uses various cookie information to revalidate a user without asking for a new login. This is triggered wh
Parameters
- $restoreSessionInfo : array<string|int, mixed>
-
-- restore array that was passed to the constructor (and is documented there) @param array $useroptions -- User options to pass to fetchUserinfo
- $useroptions : mixed
Return values
mixed —rememberSession()
Attempt to create a new session for the user without asking for a new login
protected
rememberSession(array<string|int, mixed> $restoreSessionInfo, mixed $useroptions) : mixed
This uses various cookie information to revalidate a user without asking for a new login. This is triggered wh
Parameters
- $restoreSessionInfo : array<string|int, mixed>
-
-- restore array that was passed to the constructor (and is documented there) @param array $useroptions -- User options to pass to fetchUserinfo
- $useroptions : mixed