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
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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