PHP Класс ElggSession, Elgg

This class is intended to extend the $_SESSION magic variable by providing an API hook to plug in other values. Primarily this is intended to provide a way of supplying "logged in user" details without touching the session (which can cause problems when accessed server side). If a value is present in the session then that value is returned, otherwise a plugin hook 'session:get', '$var' is called, where $var is the variable being requested. Setting values will store variables in the session in the normal way. LIMITATIONS: You can not access multidimensional arrays This is EXPERIMENTAL.
Наследование: implements ArrayAccess
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$ignore_access boolean
$logged_in_user ElggUser | null
$storage Symfony\Component\HttpFoundation\Session\SessionInterface

Открытые методы

Метод Описание
__construct ( Symfony\Component\HttpFoundation\Session\SessionInterface $storage ) Constructor
get ( string $name, mixed $default = null ) : mixed Get an attribute of the session
getId ( ) : string Get the session ID
getIgnoreAccess ( ) : boolean Get current ignore access setting.
getLoggedInUser ( ) : ElggUser | null Gets the logged in user
getLoggedInUserGuid ( ) : integer Return the current logged in user by guid.
getMock ( ) : self Get an isolated ElggSession that does not persist between requests
getName ( ) : string Get the session name
has ( string $name ) : boolean Has the attribute been defined
invalidate ( ) : boolean Invalidates the session
isAdminLoggedIn ( ) : boolean Returns whether or not the viewer is currently logged in and an admin user.
isLoggedIn ( ) : boolean Returns whether or not the user is currently logged in
isStarted ( ) : boolean Has the session been started
migrate ( boolean $destroy = false ) : boolean Migrates the session to a new session id while maintaining session attributes
remove ( string $name ) : mixed Remove an attribute
removeLoggedInUser ( ) : void Remove the logged in user
set ( string $name, mixed $value ) : void Set an attribute
setId ( string $id ) : void Set the session ID
setIgnoreAccess ( boolean $ignore = true ) : boolean Set ignore access.
setLoggedInUser ( ElggUser $user ) : void Sets the logged in user
setName ( string $name ) : void Set the session name
start ( ) : boolean Start the session

Защищенные методы

Метод Описание
generateSessionToken ( ) : void Adds a token to the session

Описание методов

__construct() публичный Метод

Constructor
public __construct ( Symfony\Component\HttpFoundation\Session\SessionInterface $storage )
$storage Symfony\Component\HttpFoundation\Session\SessionInterface The underlying Session implementation

generateSessionToken() защищенный Метод

This is used in creation of CSRF token, and is passed to the client to allow validating tokens later, even if the PHP session was destroyed.
protected generateSessionToken ( ) : void
Результат void

get() публичный Метод

Get an attribute of the session
public get ( string $name, mixed $default = null ) : mixed
$name string Name of the attribute to get
$default mixed Value to return if attribute is not set (default is null)
Результат mixed

getId() публичный Метод

Get the session ID
С версии: 1.9
public getId ( ) : string
Результат string

getIgnoreAccess() публичный Метод

Get current ignore access setting.
public getIgnoreAccess ( ) : boolean
Результат boolean

getLoggedInUser() публичный Метод

Gets the logged in user
С версии: 1.9
public getLoggedInUser ( ) : ElggUser | null
Результат ElggUser | null

getLoggedInUserGuid() публичный Метод

Return the current logged in user by guid.
См. также: elgg_get_logged_in_user_entity()
public getLoggedInUserGuid ( ) : integer
Результат integer

getMock() публичный статический Метод

Get an isolated ElggSession that does not persist between requests
public static getMock ( ) : self
Результат self

getName() публичный Метод

Get the session name
С версии: 1.9
public getName ( ) : string
Результат string

has() публичный Метод

Has the attribute been defined
С версии: 1.9
public has ( string $name ) : boolean
$name string Name of the attribute
Результат boolean

invalidate() публичный Метод

Deletes session data and session persistence. Starts a new session.
С версии: 1.9
public invalidate ( ) : boolean
Результат boolean

isAdminLoggedIn() публичный Метод

Returns whether or not the viewer is currently logged in and an admin user.
public isAdminLoggedIn ( ) : boolean
Результат boolean

isLoggedIn() публичный Метод

Returns whether or not the user is currently logged in
public isLoggedIn ( ) : boolean
Результат boolean

isStarted() публичный Метод

Has the session been started
С версии: 1.9
public isStarted ( ) : boolean
Результат boolean

migrate() публичный Метод

Migrates the session to a new session id while maintaining session attributes
С версии: 1.9
public migrate ( boolean $destroy = false ) : boolean
$destroy boolean Whether to delete the session or let gc handle clean up
Результат boolean

remove() публичный Метод

Remove an attribute
С версии: 1.9
public remove ( string $name ) : mixed
$name string The name of the attribute to remove
Результат mixed The removed attribute

removeLoggedInUser() публичный Метод

Remove the logged in user
С версии: 1.9
public removeLoggedInUser ( ) : void
Результат void

set() публичный Метод

Set an attribute
public set ( string $name, mixed $value ) : void
$name string Name of the attribute to set
$value mixed Value to be set
Результат void

setId() публичный Метод

Set the session ID
С версии: 1.9
public setId ( string $id ) : void
$id string Session ID
Результат void

setIgnoreAccess() публичный Метод

Set ignore access.
public setIgnoreAccess ( boolean $ignore = true ) : boolean
$ignore boolean Ignore access
Результат boolean Previous setting

setLoggedInUser() публичный Метод

Sets the logged in user
С версии: 1.9
public setLoggedInUser ( ElggUser $user ) : void
$user ElggUser The user who is logged in
Результат void

setName() публичный Метод

Set the session name
С версии: 1.9
public setName ( string $name ) : void
$name string Session name
Результат void

start() публичный Метод

Start the session
С версии: 1.9
public start ( ) : boolean
Результат boolean

Описание свойств

$ignore_access защищенное свойство

protected bool $ignore_access
Результат boolean

$logged_in_user защищенное свойство

protected ElggUser|null $logged_in_user
Результат ElggUser | null

$storage защищенное свойство

protected SessionInterface,Symfony\Component\HttpFoundation\Session $storage
Результат Symfony\Component\HttpFoundation\Session\SessionInterface