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 60
__construct(IRequest $request, IResponse $response)

No description

Parameters

IRequest $request
IResponse $response

at line 72
void start()

Starts and initializes session data.

Return Value

void

Exceptions

InvalidStateException

at line 159
bool isStarted()

Has been session started?

Return Value

bool

at line 169
void close()

Ends the current session and store session data.

Return Value

void

at line 183
void destroy()

Destroys all data registered to a session.

Return Value

void

at line 203
bool exists()

Does session exists for the current request?

Return Value

bool

at line 214
void regenerateId()

Regenerates the session ID.

Return Value

void

Exceptions

InvalidStateException

at line 237
string getId()

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

Return Value

string

at line 248
Session setName($name)

Sets the session name to a specified one.

Parameters

$name

Return Value

Session

at line 265
string getName()

Gets the session name.

Return Value

string

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

Returns specified session section.

Parameters

$section
$class

Return Value

SessionSection

Exceptions

InvalidArgumentException

at line 292
bool hasSection($section)

Checks if a session section exist and is not empty.

Parameters

$section

Return Value

bool

at line 306
ArrayIterator getIterator()

Iteration over all sections.

Return Value

ArrayIterator

at line 326
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 361
Session setOptions(array $options)

Sets session options.

Parameters

array $options

Return Value

Session

Exceptions

NotSupportedException
InvalidStateException

at line 386
array getOptions()

Returns all session options.

Return Value

array

at line 449
Session setExpiration($time)

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

Parameters

$time

Return Value

Session

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

Sets the session cookie parameters.

Parameters

$path
$domain
$secure

Return Value

Session

at line 488
array getCookieParameters()

Returns the session cookie parameters.

Return Value

array

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

at line 498
Session setSavePath($path)

Sets path of the directory used to save session data.

Parameters

$path

Return Value

Session

at line 510
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 527
Session setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Parameters

SessionHandlerInterface $handler

Return Value

Session