vBulletin 5.6.5 API

vB_Session_Api extends vB_Session
in package

Class to handle sessions

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

Table of Contents

$created  : bool
Whether the session was created or existed previously
$apiclient  : array<string|int, mixed>
$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.
$vBApiParamsToVerify  : mixed
$vBApiRequests  : mixed
__construct()  : mixed
Constructor. Attempts to grab a session that matches parameters, but will create one if it can't.
__serialize()  : mixed
__sleep()  : mixed
__unserialize()  : mixed
__wakeup()  : mixed
clearChannelPerms()  : mixed
clearUserInfo()  : mixed
Clear user cached info. Primarily needed for cleaning cache in memory.
createSession()  : mixed
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
getApiClient()  : mixed
getChannelPerms()  : mixed
getNewSession()  : vB_Session
Returns a new session of the type specified by defined constants
getRememberMeToken()  : mixed
getSession()  : 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
refetchApiClientFromDB()  : mixed
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
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
validateApiSession()  : mixed

Properties

$created

Whether the session was created or existed previously

public bool $created = alse

$apiclient

protected array<string|int, mixed> $apiclient

$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()

$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()

$vBApiParamsToVerify

private static mixed $vBApiParamsToVerify = array()

$vBApiRequests

private static mixed $vBApiRequests = array()

Methods

__construct()

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

public __construct(vB_dB_Assertor $dBAssertor, vB_Datastore $datastore, array<string|int, mixed> $config[, mixed $sessionhash = '' ][, array<string|int, mixed> $vbApiParamsToVerify = array() ][, array<string|int, mixed> $vBApiRequests = array() ]) : mixed
Parameters
$dBAssertor : vB_dB_Assertor
$datastore : vB_Datastore
$config : array<string|int, mixed>
$sessionhash : mixed = ''
$vbApiParamsToVerify : array<string|int, mixed> = array()
$vBApiRequests : array<string|int, mixed> = array()
Return values
mixed

__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

createSession()

public static createSession(mixed $vbApiParamsToVerify, mixed $vBApiRequests) : mixed
Parameters
$vbApiParamsToVerify : mixed
$vBApiRequests : 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
throws
vB_Exception
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>

getApiClient()

public getApiClient() : mixed
Return values
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
global

array $VB_API_PARAMS_TO_VERIFY - Defined in api.php

global

array $VB_API_REQUESTS - Defined in api.php

Return values
vB_Session

getRememberMeToken()

public getRememberMeToken() : mixed
Return values
mixed

getSession()

public static getSession(mixed $userId[, mixed $sessionHash = '' ][, mixed $dBAssertor = null ][, mixed $datastore = null ][, mixed $config = null ]) : mixed
Parameters
$userId : mixed
$sessionHash : mixed = ''
$dBAssertor : mixed = null
$datastore : mixed = null
$config : mixed = null
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

refetchApiClientFromDB()

public refetchApiClientFromDB() : 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([mixed $updatetimeout = true ]) : bool
Parameters
$updatetimeout : mixed = true

Whether to update the table to reset the timeout

Return values
bool

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, array<string|int, mixed> $useroptions) : mixed
Parameters
$restoreSessionInfo : array<string|int, mixed>

This is ignored (see parent class for details of what it usually does)

$useroptions : array<string|int, mixed>
Return values
mixed

validateApiSession()

protected validateApiSession(mixed $vbApiParamsToVerify, mixed $vBApiRequests) : mixed
Parameters
$vbApiParamsToVerify : mixed
$vBApiRequests : mixed
Return values
mixed

Search results