PHP Класс AppserverIo\Appserver\ServletEngine\Http\Session

You may access the currently active session in userland code. In order to do this, inject TYPO3\Flow\Session\SessionInterface and NOT just TYPO3\Flow\Session\Session. 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.
Автор: Tim Wagner ([email protected])
Наследование: implements AppserverIo\Psr\Servlet\ServletSessionInterface
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( mixed $id, string $name, integer | DateTime $lifetime, integer | null $maximumAge, string | null $domain, string $path, boolean $secure, boolean $httpOnly ) Constructor to initialize a newly created 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.
checksum ( ) : string Returns the checksum for this session instance.
destroy ( string $reason ) : void Explicitly destroys all session data.
emptyInstance ( ) : AppserverIo\Psr\Servlet\ServletSessionInterface Creates a new and empty session instance.
getData ( string $key ) : mixed Returns the data associated with the given key.
getDomain ( ) : string | null Returns the host to which the user agent will send this cookie.
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.
getLifetime ( ) : integer | DateTime Returns date and time after the session expires.
getMaximumAge ( ) : integer | null Returns the number of seconds until the session expires.
getName ( ) : string Returns the session name.
getPath ( ) : string Returns the path describing the scope of this cookie.
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.
init ( mixed $id, string $name, integer | DateTime $lifetime, integer | null $maximumAge, string | null $domain, string $path, boolean $secure, boolean $httpOnly, integer | null $lastActivityTimestamp = null ) : void Initializes the session with the passed data.
isHttpOnly ( ) : boolean Returns if this session should only be used through the HTTP protocol.
isSecure ( ) : boolean Returns if this session should only be sent through a "secure" channel by the user agent.
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
removeData ( string $key ) : void Removes the session data entry $key from the session.
removeTag ( string $tag ) : void Removes the specified tag from this session.
resume ( ) : integer Resumes an existing session, if any.
setDomain ( string $domain ) : void Sets the host to which the user agent will send this cookie.
setHttpOnly ( boolean $httpOnly = true ) : void Sets the flag that this session should only be used through the HTTP protocol.
setId ( string $id ) : void Sets the current session identifier.
setLifetime ( integer | DateTime $lifetime ) : void Sets date and time after the session expires.
setMaximumAge ( integer $maximumAge ) : void Sets the number of seconds until the session expires.
setName ( string $name ) : void Sets the session name.
setPath ( string $path ) : void Sets the path describing the scope of this cookie.
setSecure ( boolean $secure = true ) : void Sets the flag that this session should only be sent through a "secure" channel by the user agent.
start ( ) : void Starts the session, if it has not been already started

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

Метод Описание
autoExpire ( ) : boolean Automatically expires the session if the user has been inactive for too long.

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

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

Constructor to initialize a newly created session.
public __construct ( mixed $id, string $name, integer | DateTime $lifetime, integer | null $maximumAge, string | null $domain, string $path, boolean $secure, boolean $httpOnly )
$id mixed The session ID
$name string The session name
$lifetime integer | DateTime Date and time after the session expires
$maximumAge integer | null Number of seconds until the session expires
$domain string | null The host to which the user agent will send this cookie
$path string The path describing the scope of this cookie
$secure boolean If this cookie should only be sent through a "secure" channel by the user agent
$httpOnly boolean If this cookie should only be used through the HTTP protocol

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 TRUE if the session can be resumed, else FALSE

checksum() публичный метод

Returns the checksum for this session instance.
public checksum ( ) : string
Результат string The checksum

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

Explicitly destroys all session data.
public destroy ( string $reason ) : void
$reason string The reason why the session has been destroyed
Результат void

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

Creates a new and empty session instance.
public static emptyInstance ( ) : AppserverIo\Psr\Servlet\ServletSessionInterface
Результат AppserverIo\Psr\Servlet\ServletSessionInterface The empty, but initialized session instance

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

getDomain() публичный метод

Returns the host to which the user agent will send this cookie.
public getDomain ( ) : string | null
Результат string | null The host to which the user agent will send this cookie

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

getLifetime() публичный метод

Returns date and time after the session expires.
public getLifetime ( ) : integer | DateTime
Результат integer | DateTime The date and time after the session expires

getMaximumAge() публичный метод

Returns the number of seconds until the session expires.
public getMaximumAge ( ) : integer | null
Результат integer | null Number of seconds until the session expires

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

Returns the session name.
public getName ( ) : string
Результат string The session name

getPath() публичный метод

Returns the path describing the scope of this cookie.
public getPath ( ) : string
Результат string The path describing the scope of this cookie

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

init() публичный метод

Initializes the session with the passed data.
public init ( mixed $id, string $name, integer | DateTime $lifetime, integer | null $maximumAge, string | null $domain, string $path, boolean $secure, boolean $httpOnly, integer | null $lastActivityTimestamp = null ) : void
$id mixed The session ID
$name string The session name
$lifetime integer | DateTime Date and time after the session expires
$maximumAge integer | null Number of seconds until the session expires
$domain string | null The host to which the user agent will send this cookie
$path string The path describing the scope of this cookie
$secure boolean If this cookie should only be sent through a "secure" channel by the user agent
$httpOnly boolean If this cookie should only be used through the HTTP protocol
$lastActivityTimestamp integer | null The timestamp when the session has been touched the last time
Результат void

isHttpOnly() публичный метод

Returns if this session should only be used through the HTTP protocol.
public isHttpOnly ( ) : boolean
Результат boolean TRUE if the session should only be used through the HTTP protocol

isSecure() публичный метод

Returns if this session should only be sent through a "secure" channel by the user agent.
public isSecure ( ) : boolean
Результат boolean TRUE if the session should only be sent through a "secure" channel, else FALSE

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

removeData() публичный метод

Removes the session data entry $key from the session.
public removeData ( string $key ) : void
$key string Entry identifier of the session data to remove
Результат 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

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

setDomain() публичный метод

Sets the host to which the user agent will send this cookie.
public setDomain ( string $domain ) : void
$domain string The host to which the user agent will send this cookie
Результат void

setHttpOnly() публичный метод

Sets the flag that this session should only be used through the HTTP protocol.
public setHttpOnly ( boolean $httpOnly = true ) : void
$httpOnly boolean TRUE if the session should only be used through the HTTP protocol
Результат void

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

Sets the current session identifier.
public setId ( string $id ) : void
$id string The current session identifier
Результат void

setLifetime() публичный метод

Sets date and time after the session expires.
public setLifetime ( integer | DateTime $lifetime ) : void
$lifetime integer | DateTime The date and time after the session expires
Результат void

setMaximumAge() публичный метод

Sets the number of seconds until the session expires.
public setMaximumAge ( integer $maximumAge ) : void
$maximumAge integer Number of seconds until the session expires
Результат void

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

Sets the session name.
public setName ( string $name ) : void
$name string The session name
Результат void

setPath() публичный метод

Sets the path describing the scope of this cookie.
public setPath ( string $path ) : void
$path string The path describing the scope of this cookie
Результат void

setSecure() публичный метод

Sets the flag that this session should only be sent through a "secure" channel by the user agent.
public setSecure ( boolean $secure = true ) : void
$secure boolean TRUE if the session should only be sent through a "secure" channel, else FALSE
Результат void

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

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