abstract class vB_Session

Class to handle sessions

Creates, updates, and validates sessions; retrieves user info of browsing user

Traits

Properties

protected vB_dB_Assertor $dBAssertor
protected vB_Datastore $datastore
protected array $config
protected array $vars The individual session variables. Equivalent to $session from the past.
protected $data
protected $cookietimeout
protected $rememberMeToken
protected array $db_fields A list of variables in the $vars member that are in the database. Includes their types.
protected array $changes An array of changes. Used to prevent superfluous updates from being made.
$created
protected array $userinfo Information about the user that this session belongs to.
protected $sessionIdHash
protected string $cpsessionHash cpsessionhash is a special session hash for admins and moderators

Methods

__sleep()

No description

__wakeup()

No description

createSessionIdHash()

Sets the attribute sessionIdHash

loadExistingSession($sessionhash, $restoreSessionInfo)

No description

fetchStoredSession($sessionhash, $restoreSessionInfo = array())

No description

rememberSession($restoreSessionInfo, $useroptions)

Attempt to create a new session for the user without asking for a new login

rememberFacebook($restoreSessionInfo, $useroptions)

Attempt to create a new session for the user from facebook

array
fetchUserForRemember($userid, $useroptions)

Get the user info based on the useroptions

__construct(vB_DB_Assertor $dBAssertor, vB_Datastore $datastore, array $config, string $sessionhash = '', array $restoreSessionInfo = array(), integer $styleid = 0, integer $languageid = 0)

Constructor. Attempts to grab a session that matches parameters, but will create one if it can't.

static 
getNewSession($dBAssertor, $datastore, $config, $sessionhash = '', $userid = 0, $password = '', $styleid = 0, $languageid = 0)

No description

string
getSessionIdHash()

Returns the sessionIdHash

save()

Saves the session into the database by inserting it or updating an existing one.

delete()

Deletes the session from the session store.

set(string $key, mixed $value)

Sets a session variable and updates the change list.

setChannelPerms($key, $perms)

No description

getChannelPerms($key)

No description

clearChannelPerms()

No description

getRememberMeToken()

No description

mixed
get(string $key)

Gets a session variable.

bool
isCreated()

Returns whether the session was created

array
getAllVars()

Returns an array with all session vars

setSessionVars($userId)

No description

string
fetch_sessionhash()

Fetches a valid sessionhash value, not necessarily the one tied to this session.

string
fetch_substr_ip($ip, $length = null)

Returns the IP address with the specified number of octets removed

array
fetch_session(integer $userid = 0)

Fetches a default session. Used when creating a new session.

loadPhraseGroups()

Called after setting phrasegroups, adds new phrases to userinfo

loadLanguage()

Loads basic language information

array
fetch_userinfo()

Returns appropriate user info for the owner of this session.

mix
fetch_userinfo_value($value)

Returns appropriate value from the user info array for the owner of this session.

array
doLastVisitUpdate(integer $lastvisit = 0, integer $lastactivity = 0)

Updates the last visit and last activity times for guests and registered users (differently).

string
fetchCpsessionHash(bool $renew = false)

Create new cpsession for the user and insert it into database or fetch current existing one

setCpsessionHash($cpsessionhash)

No description

bool
validateCpsession(bool $updatetimeout = true)

Validate cpsession

clearUserInfo()

Clear user cached info. Primarily needed for cleaning cache in memory.

loadUserInfo(Array $nocache = false)

Loads user info and stores it in session object property ($this->userinfo) for a given user regarding options being passed.

Details

in vB_Trait_NoSerialize at line 15
__sleep()

in vB_Trait_NoSerialize at line 20
__wakeup()

at line 121
protected createSessionIdHash()

Sets the attribute sessionIdHash

at line 127
protected loadExistingSession($sessionhash, $restoreSessionInfo)

Parameters

$sessionhash
$restoreSessionInfo

at line 274
protected fetchStoredSession($sessionhash, $restoreSessionInfo = array())

Parameters

$sessionhash
$restoreSessionInfo

at line 364
protected rememberSession($restoreSessionInfo, $useroptions)

Attempt to create a new session for the user without asking for a new login

This uses various cookie information to revalidate a user without asking for a new login. This is triggered wh

Parameters

$restoreSessionInfo
$useroptions

at line 398
protected rememberFacebook($restoreSessionInfo, $useroptions)

Attempt to create a new session for the user from facebook

This uses various cookie information to revalidate a user without asking for a new login. This is triggered wh

Parameters

$restoreSessionInfo
$useroptions

at line 449
protected array fetchUserForRemember($userid, $useroptions)

Get the user info based on the useroptions

Parameters

$userid
$useroptions

Return Value

array user info array

at line 483
protected __construct(vB_DB_Assertor $dBAssertor, vB_Datastore $datastore, array $config, string $sessionhash = '', array $restoreSessionInfo = array(), integer $styleid = 0, integer $languageid = 0)

Constructor. Attempts to grab a session that matches parameters, but will create one if it can't.

Parameters

vB_DB_Assertor $dBAssertor
vB_Datastore $datastore
array $config -- vBulletin config array
string $sessionhash Previously specified sessionhash
array $restoreSessionInfo -- 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".
integer $styleid Style ID for this session
integer $languageid Language ID for this session

at line 538
static getNewSession($dBAssertor, $datastore, $config, $sessionhash = '', $userid = 0, $password = '', $styleid = 0, $languageid = 0)

Parameters

$dBAssertor
$datastore
$config
$sessionhash
$userid
$password
$styleid
$languageid

at line 562
string getSessionIdHash()

Returns the sessionIdHash

Return Value

string

at line 570
save()

Saves the session into the database by inserting it or updating an existing one.

at line 629
delete()

Deletes the session from the session store.

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.

at line 650
set(string $key, mixed $value)

Sets a session variable and updates the change list.

Parameters

string $key Name of session variable to update
mixed $value Value to update it with

at line 660
setChannelPerms($key, $perms)

Parameters

$key
$perms

at line 675
getChannelPerms($key)

Parameters

$key

at line 684
clearChannelPerms()

at line 690
getRememberMeToken()

at line 701
mixed get(string $key)

Gets a session variable.

Parameters

string $key
  • Name of session variable

Return Value

mixed
  • Value of the key, NULL if not found

at line 714
bool isCreated()

Returns whether the session was created

Return Value

bool

at line 724
array getAllVars()

Returns an array with all session vars

Return Value

array

at line 729
setSessionVars($userId)

Parameters

$userId

at line 738
string fetch_sessionhash()

Fetches a valid sessionhash value, not necessarily the one tied to this session.

Return Value

string 32-character sessionhash

at line 748
protected string fetch_substr_ip($ip, $length = null)

Returns the IP address with the specified number of octets removed

Parameters

$ip
$length

Return Value

string truncated IP address

at line 765
protected array fetch_session(integer $userid = 0)

Fetches a default session. Used when creating a new session.

Parameters

integer $userid User ID the session should be for

Return Value

array Array of session variables

at line 796
loadPhraseGroups()

Called after setting phrasegroups, adds new phrases to userinfo

at line 819
loadLanguage()

Loads basic language information

at line 886
array fetch_userinfo()

Returns appropriate user info for the owner of this session.

Return Value

array Array of user information.

at line 983
mix fetch_userinfo_value($value)

Returns appropriate value from the user info array for the owner of this session.

Parameters

$value

Return Value

mix value of user information.

at line 1006
array doLastVisitUpdate(integer $lastvisit = 0, integer $lastactivity = 0)

Updates the last visit and last activity times for guests and registered users (differently).

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

integer $lastvisit Time stamp for last visit time (guest only)
integer $lastactivity Time stamp for last activity time (guest only)

Return Value

array Updated values for setting cookies (guest only)

at line 1089
string fetchCpsessionHash(bool $renew = false)

Create new cpsession for the user and insert it into database or fetch current existing one

Parameters

bool $renew Whether to renew cpsession hash (Create a new one and drop the old one)

Return Value

string The new cpsession hash

Exceptions

vB_Exception

at line 1119
setCpsessionHash($cpsessionhash)

Parameters

$cpsessionhash

at line 1131
bool validateCpsession(bool $updatetimeout = true)

Validate cpsession

Parameters

bool $updatetimeout Whether to update the table to reset the timeout

Return Value

bool

at line 1176
clearUserInfo()

Clear user cached info. Primarily needed for cleaning cache in memory.

at line 1199
protected loadUserInfo(Array $nocache = false)

Loads user info and stores it in session object property ($this->userinfo) for a given user regarding options being passed.

@param Int Userid to load info

Parameters

Array $nocache Extra data passed to consider while loading user information. 'Options' => list of userinfo options (check vB_Api_User USERINFO_XXXX constants) 'Languageid' => id from the language to load info from. @param Bool Determines whether or not fetch cached information.