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.
상속: implements AppserverIo\Psr\Servlet\ServletSessionInterface
파일 보기 프로젝트 열기: appserver-io/appserver 1 사용 예제들

공개 메소드들

메소드 설명
__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