PHP Класс Neos\Flow\Session\Session

You may access the currently active session in userland code. In order to do this, inject SessionInterface and NOT just the Session object. The former will be a unique instance (singleton) representing the current session while the latter would be a completely new session instance! You can use the Session Manager for accessing sessions which are not currently active. Note that Flow's bootstrap (that is, Neos\Flow\Core\Scripts) will try to resume a possibly existing session automatically. If a session could be resumed during that phase already, calling start() at a later stage will be a no-operation.
См. также: SessionManager
Наследование: implements Neos\Flow\Session\SessionInterface
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$bootstrap Neos\Flow\Core\Bootstrap Bootstrap for retrieving the current HTTP request
$garbageCollectionMaximumPerRun integer
$garbageCollectionProbability float
$inactivityTimeout integer
$lastActivityTimestamp integer
$metaDataCache Neos\Cache\Frontend\VariableFrontend Meta data cache for this session
$now integer
$objectManager Neos\Flow\ObjectManagement\ObjectManagerInterface
$remote boolean If this session is remote or the "current" session
$request Neos\Flow\Http\Request
$response Neos\Flow\Http\Response
$sessionCookie Neos\Flow\Http\Cookie
$sessionCookieDomain string
$sessionCookieHttpOnly boolean
$sessionCookieLifetime integer
$sessionCookieName string
$sessionCookiePath string
$sessionCookieSecure boolean
$sessionIdentifier string The session identifier
$started boolean If this session has been started
$storageCache Neos\Cache\Frontend\VariableFrontend Storage cache for this session
$storageIdentifier string Internal identifier used for storing session data in the cache
$systemLogger Neos\Flow\Log\SystemLoggerInterface
$tags array

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

Метод Описание
__construct ( string $sessionIdentifier = null, string $storageIdentifier = null, integer $lastActivityTimestamp = null, array $tags = [] ) Constructs this session
addTag ( string $tag ) : void Tags this session with the given tag.
canBeResumed ( ) : boolean Returns TRUE if there is a session that can be resumed.
close ( ) : void Explicitly writes and closes the session
collectGarbage ( ) : integer Iterates over all existing sessions and removes their data if the inactivity timeout was reached.
destroy ( string $reason = null ) : void Explicitly destroys all session data
getData ( string $key ) : mixed Returns the data associated with the given key.
getId ( ) : string Returns the current session identifier
getLastActivityTimestamp ( ) : integer Returns the unix time stamp marking the last point in time this session has been in use.
getTags ( ) : array Returns the tags this session has been tagged with.
hasKey ( string $key ) : boolean Returns TRUE if a session data entry $key is available.
initializeObject ( ) : void
injectSettings ( array $settings ) : void Injects the Flow settings
isRemote ( ) : boolean Tells if the session is local (the current session bound to the current HTTP request) or remote (retrieved through the Session Manager).
isStarted ( ) : boolean Tells if the session has been started already.
putData ( string $key, mixed $data ) : void Stores the given data under the given key in the session
removeTag ( string $tag ) : void Removes the specified tag from this session.
renewId ( ) : string Generates and propagates a new session ID and transfers all existing data to the new session.
resume ( ) : integer Resumes an existing session, if any.
shutdownObject ( ) : void Shuts down this session
start ( ) : void Starts the session, if it has not been already started
touch ( ) : void Updates the last activity time to "now".

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

Метод Описание
autoExpire ( ) : boolean Automatically expires the session if the user has been inactive for too long.
initializeHttpAndCookie ( Neos\Flow\Http\HttpRequestHandlerInterface $requestHandler ) : void Initialize request, response and session cookie
removeSessionMetaDataCacheEntry ( string $sessionIdentifier ) : void Removes the session info cache entry for the specified session.
storeAuthenticatedAccountsInfo ( array $tokens ) : void Stores some information about the authenticated accounts in the session data.
writeSessionMetaDataCacheEntry ( ) : void Writes the cache entry containing information about the session, such as the last activity time and the storage identifier.

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

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

If $sessionIdentifier is specified, this constructor will create a session instance representing a remote session. In that case $storageIdentifier and $lastActivityTimestamp are also required arguments. Session instances MUST NOT be created manually! They should be retrieved via the Session Manager or through dependency injection (use SessionInterface!).
public __construct ( string $sessionIdentifier = null, string $storageIdentifier = null, integer $lastActivityTimestamp = null, array $tags = [] )
$sessionIdentifier string The public session identifier which is also used in the session cookie
$storageIdentifier string The private storage identifier which is used for storage cache entries
$lastActivityTimestamp integer Unix timestamp of the last known activity for this session
$tags array A list of tags set for this session

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

Note that third-party libraries might also tag your session. Therefore it is recommended to use namespaced tags such as "Acme-Demo-MySpecialTag".
public addTag ( string $tag ) : void
$tag string The tag – must match be a valid cache frontend tag
Результат void

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

Automatically expires the session if the user has been inactive for too long.
protected autoExpire ( ) : boolean
Результат boolean TRUE if the session expired, FALSE if not

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

If a to-be-resumed session was inactive for too long, this function will trigger the expiration of that session. An expired session cannot be resumed. NOTE that this method does a bit more than the name implies: Because the session info data needs to be loaded, this method stores this data already so it doesn't have to be loaded again once the session is being used.
public canBeResumed ( ) : boolean
Результат boolean

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

Explicitly writes and closes the session
public close ( ) : void
Результат void

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

Iterates over all existing sessions and removes their data if the inactivity timeout was reached.
public collectGarbage ( ) : integer
Результат integer The number of outdated entries removed

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

Explicitly destroys all session data
public destroy ( string $reason = null ) : void
$reason string A reason for destroying the session – used by the LoggingAspect
Результат void

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

Returns the data associated with the given key.
public getData ( string $key ) : mixed
$key string An identifier for the content stored in the session.
Результат mixed The contents associated with the given key

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

Returns the current session identifier
public getId ( ) : string
Результат string The current session identifier

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

For the current (local) session, this method will always return the current time. For a remote session, the unix timestamp will be returned.
public getLastActivityTimestamp ( ) : integer
Результат integer unix timestamp

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

Returns the tags this session has been tagged with.
public getTags ( ) : array
Результат array The tags or an empty array if there aren't any

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

Returns TRUE if a session data entry $key is available.
public hasKey ( string $key ) : boolean
$key string Entry identifier of the session data
Результат boolean

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

Initialize request, response and session cookie
protected initializeHttpAndCookie ( Neos\Flow\Http\HttpRequestHandlerInterface $requestHandler ) : void
$requestHandler Neos\Flow\Http\HttpRequestHandlerInterface
Результат void

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

public initializeObject ( ) : void
Результат void

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

Injects the Flow settings
public injectSettings ( array $settings ) : void
$settings array Settings of the Flow package
Результат void

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

Tells if the session is local (the current session bound to the current HTTP request) or remote (retrieved through the Session Manager).
public isRemote ( ) : boolean
Результат boolean TRUE if the session is remote, FALSE if this is the current session

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

Tells if the session has been started already.
public isStarted ( ) : boolean
Результат boolean

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

Stores the given data under the given key in the session
public putData ( string $key, mixed $data ) : void
$key string The key under which the data should be stored
$data mixed The data to be stored
Результат void

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

Note that this function does only remove the "head" cache entry, not the related data referred to by the storage identifier.
protected removeSessionMetaDataCacheEntry ( string $sessionIdentifier ) : void
$sessionIdentifier string
Результат void

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

Removes the specified tag from this session.
public removeTag ( string $tag ) : void
$tag string The tag – must match be a valid cache frontend tag
Результат void

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

Generates and propagates a new session ID and transfers all existing data to the new session.
public renewId ( ) : string
Результат string The new session ID

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

Resumes an existing session, if any.
public resume ( ) : integer
Результат integer If a session was resumed, the inactivity of since the last request is returned

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

This method must not be called manually – it is invoked by Flow's object management.
public shutdownObject ( ) : void
Результат void

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

Starts the session, if it has not been already started
public start ( ) : void
Результат void

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

This method will check if a session has already been started, which is the case after tokens relying on a session have been authenticated: the UsernamePasswordToken does, for example, start a session in its authenticate() method. Because more than one account can be authenticated at a time, this method accepts an array of tokens instead of a single account. Note that if a session is started after tokens have been authenticated, the session will NOT be tagged with authenticated accounts.
protected storeAuthenticatedAccountsInfo ( array $tokens ) : void
$tokens array
Результат void

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

Updates the last activity time to "now".
public touch ( ) : void
Результат void

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

This function does not write the whole session _data_ into the storage cache, but only the "head" cache entry containing meta information. The session cache entry is also tagged with "session", the session identifier and any custom tags of this session, prefixed with TAG_PREFIX.
protected writeSessionMetaDataCacheEntry ( ) : void
Результат void

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

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

Bootstrap for retrieving the current HTTP request
protected Bootstrap,Neos\Flow\Core $bootstrap
Результат Neos\Flow\Core\Bootstrap

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

protected int $garbageCollectionMaximumPerRun
Результат integer

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

protected float $garbageCollectionProbability
Результат float

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

protected int $inactivityTimeout
Результат integer

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

protected int $lastActivityTimestamp
Результат integer

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

Meta data cache for this session
protected VariableFrontend,Neos\Cache\Frontend $metaDataCache
Результат Neos\Cache\Frontend\VariableFrontend

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

protected int $now
Результат integer

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

protected ObjectManagerInterface,Neos\Flow\ObjectManagement $objectManager
Результат Neos\Flow\ObjectManagement\ObjectManagerInterface

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

If this session is remote or the "current" session
protected bool $remote
Результат boolean

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

protected Request,Neos\Flow\Http $request
Результат Neos\Flow\Http\Request

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

protected Response,Neos\Flow\Http $response
Результат Neos\Flow\Http\Response

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

protected Cookie,Neos\Flow\Http $sessionCookie
Результат Neos\Flow\Http\Cookie

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

protected string $sessionCookieDomain
Результат string

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

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

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

protected int $sessionCookieLifetime
Результат integer

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

protected string $sessionCookieName
Результат string

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

protected string $sessionCookiePath
Результат string

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

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

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

The session identifier
protected string $sessionIdentifier
Результат string

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

If this session has been started
protected bool $started
Результат boolean

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

Storage cache for this session
protected VariableFrontend,Neos\Cache\Frontend $storageCache
Результат Neos\Cache\Frontend\VariableFrontend

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

Internal identifier used for storing session data in the cache
protected string $storageIdentifier
Результат string

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

protected SystemLoggerInterface,Neos\Flow\Log $systemLogger
Результат Neos\Flow\Log\SystemLoggerInterface

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

protected array $tags
Результат array