PHP Class Nette\Http\Session

Inheritance: use trait Nette\SmartObject
Show file Open project: nette/http Class Usage Examples

Public Methods

Method Description
__construct ( Nette\Http\IRequest $request, Nette\Http\IResponse $response )
clean ( ) : void Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.
close ( ) : void Ends the current session and store session data.
destroy ( ) : void Destroys all data registered to a session.
exists ( ) : boolean Does session exists for the current request?
getCookieParameters ( ) : array Returns the session cookie parameters.
getId ( ) : string Returns the current session ID. Don't make dependencies, can be changed for each request.
getIterator ( ) : ArrayIterator Iteration over all sections.
getName ( ) : string Gets the session name.
getOptions ( ) : array Returns all session options.
getSection ( $section, $class = SessionSection::class ) : SessionSection Returns specified session section.
hasSection ( $section ) : boolean Checks if a session section exist and is not empty.
isStarted ( ) : boolean Has been session started?
regenerateId ( ) : void Regenerates the session ID.
setCookieParameters ( $path, $domain = NULL, $secure = NULL ) : self Sets the session cookie parameters.
setExpiration ( $time ) : self Sets the amount of time allowed between requests before the session will be terminated.
setHandler ( SessionHandlerInterface $handler ) : self Sets user session handler.
setName ( $name ) : self Sets the session name to a specified one.
setOptions ( array $options ) : self Sets session options.
setSavePath ( $path ) : self Sets path of the directory used to save session data.
setStorage ( Nette\Http\ISessionStorage $storage ) : self
start ( ) : void Starts and initializes session data.

Private Methods

Method Description
configure ( array $config ) : void Configures session environment.
sendCookie ( ) : void Sends the session cookies.

Method Details

__construct() public method

public __construct ( Nette\Http\IRequest $request, Nette\Http\IResponse $response )
$request Nette\Http\IRequest
$response Nette\Http\IResponse

clean() public method

Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.
public clean ( ) : void
return void

close() public method

Ends the current session and store session data.
public close ( ) : void
return void

destroy() public method

Destroys all data registered to a session.
public destroy ( ) : void
return void

exists() public method

Does session exists for the current request?
public exists ( ) : boolean
return boolean

getCookieParameters() public method

Returns the session cookie parameters.
public getCookieParameters ( ) : array
return array containing items: lifetime, path, domain, secure, httponly

getId() public method

Returns the current session ID. Don't make dependencies, can be changed for each request.
public getId ( ) : string
return string

getIterator() public method

Iteration over all sections.

getName() public method

Gets the session name.
public getName ( ) : string
return string

getOptions() public method

Returns all session options.
public getOptions ( ) : array
return array

getSection() public method

Returns specified session section.
public getSection ( $section, $class = SessionSection::class ) : SessionSection
return SessionSection

hasSection() public method

Checks if a session section exist and is not empty.
public hasSection ( $section ) : boolean
return boolean

isStarted() public method

Has been session started?
public isStarted ( ) : boolean
return boolean

regenerateId() public method

Regenerates the session ID.
public regenerateId ( ) : void
return void

setCookieParameters() public method

Sets the session cookie parameters.
public setCookieParameters ( $path, $domain = NULL, $secure = NULL ) : self
return self

setExpiration() public method

Sets the amount of time allowed between requests before the session will be terminated.
public setExpiration ( $time ) : self
return self

setHandler() public method

Sets user session handler.
public setHandler ( SessionHandlerInterface $handler ) : self
$handler SessionHandlerInterface
return self

setName() public method

Sets the session name to a specified one.
public setName ( $name ) : self
return self

setOptions() public method

Sets session options.
public setOptions ( array $options ) : self
$options array
return self

setSavePath() public method

Sets path of the directory used to save session data.
public setSavePath ( $path ) : self
return self

setStorage() public method

Deprecation: use setHandler().
public setStorage ( Nette\Http\ISessionStorage $storage ) : self
$storage Nette\Http\ISessionStorage
return self

start() public method

Starts and initializes session data.
public start ( ) : void
return void