class Session extends Object

Provides access to session sections as well as session settings and management methods.

Constants

DEFAULT_FILE_LIFETIME

Default file lifetime is 3 hours

Methods

__construct(IRequest $request, IResponse $response)

No description

void
start()

Starts and initializes session data.

bool
isStarted()

Has been session started?

void
close()

Ends the current session and store session data.

void
destroy()

Destroys all data registered to a session.

bool
exists()

Does session exists for the current request?

void
regenerateId()

Regenerates the session ID.

string
getId()

Returns the current session ID. Don't make dependencies, can be changed for each request.

setName($name)

Sets the session name to a specified one.

string
getName()

Gets the session name.

getSection($section, $class = 'Nette\\Http\\SessionSection')

Returns specified session section.

bool
hasSection($section)

Checks if a session section exist and is not empty.

getIterator()

Iteration over all sections.

void
clean()

Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.

setOptions(array $options)

Sets session options.

array
getOptions()

Returns all session options.

setExpiration($time)

Sets the amount of time allowed between requests before the session will be terminated.

setCookieParameters($path, $domain = NULL, $secure = NULL)

Sets the session cookie parameters.

array
getCookieParameters()

Returns the session cookie parameters.

setSavePath($path)

Sets path of the directory used to save session data.

setStorage(ISessionStorage $storage)

Sets user session storage for PHP < 5.4. For PHP >= 5.4, use setHandler().

setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Details

at line 62
__construct(IRequest $request, IResponse $response)

No description

Parameters

IRequest $request
IResponse $response

at line 74
void start()

Starts and initializes session data.

Return Value

void

Exceptions

InvalidStateException

at line 161
bool isStarted()

Has been session started?

Return Value

bool

at line 171
void close()

Ends the current session and store session data.

Return Value

void

at line 185
void destroy()

Destroys all data registered to a session.

Return Value

void

at line 205
bool exists()

Does session exists for the current request?

Return Value

bool

at line 216
void regenerateId()

Regenerates the session ID.

Return Value

void

Exceptions

InvalidStateException

at line 239
string getId()

Returns the current session ID. Don't make dependencies, can be changed for each request.

Return Value

string

at line 250
Session setName($name)

Sets the session name to a specified one.

Parameters

$name

Return Value

Session

at line 267
string getName()

Gets the session name.

Return Value

string

at line 283
SessionSection getSection($section, $class = 'Nette\\Http\\SessionSection')

Returns specified session section.

Parameters

$section
$class

Return Value

SessionSection

Exceptions

InvalidArgumentException

at line 294
bool hasSection($section)

Checks if a session section exist and is not empty.

Parameters

$section

Return Value

bool

at line 308
ArrayIterator getIterator()

Iteration over all sections.

Return Value

ArrayIterator

at line 328
void clean()

internal  
 

Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.

Return Value

void

at line 363
Session setOptions(array $options)

Sets session options.

Parameters

array $options

Return Value

Session

Exceptions

NotSupportedException
InvalidStateException

at line 380
array getOptions()

Returns all session options.

Return Value

array

at line 448
Session setExpiration($time)

Sets the amount of time allowed between requests before the session will be terminated.

Parameters

$time

Return Value

Session

at line 473
Session setCookieParameters($path, $domain = NULL, $secure = NULL)

Sets the session cookie parameters.

Parameters

$path
$domain
$secure

Return Value

Session

at line 487
array getCookieParameters()

Returns the session cookie parameters.

Return Value

array

containing items: lifetime, path, domain, secure, httponly

at line 497
Session setSavePath($path)

Sets path of the directory used to save session data.

Parameters

$path

Return Value

Session

at line 509
Session setStorage(ISessionStorage $storage)

Sets user session storage for PHP < 5.4. For PHP >= 5.4, use setHandler().

Parameters

ISessionStorage $storage

Return Value

Session

at line 526
Session setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Parameters

SessionHandlerInterface $handler

Return Value

Session