class Session

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

Constants

DEFAULT_FILE_LIFETIME

Default file lifetime

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 = SessionSection::class)

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, $samesite = 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) deprecated

No description

setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Details

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

No description

Parameters

IRequest $request
IResponse $response

at line 70
void start()

Starts and initializes session data.

Return Value

void

Exceptions

InvalidStateException

at line 148
bool isStarted()

Has been session started?

Return Value

bool

at line 158
void close()

Ends the current session and store session data.

Return Value

void

at line 172
void destroy()

Destroys all data registered to a session.

Return Value

void

at line 192
bool exists()

Does session exists for the current request?

Return Value

bool

at line 203
void regenerateId()

Regenerates the session ID.

Return Value

void

Exceptions

InvalidStateException

at line 225
string getId()

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

Return Value

string

at line 236
Session setName($name)

Sets the session name to a specified one.

Parameters

$name

Return Value

Session

at line 253
string getName()

Gets the session name.

Return Value

string

at line 269
SessionSection getSection($section, $class = SessionSection::class)

Returns specified session section.

Parameters

$section
$class

Return Value

SessionSection

Exceptions

InvalidArgumentException

at line 280
bool hasSection($section)

Checks if a session section exist and is not empty.

Parameters

$section

Return Value

bool

at line 294
Iterator getIterator()

Iteration over all sections.

Return Value

Iterator

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

Sets session options.

Parameters

array $options

Return Value

Session

Exceptions

NotSupportedException
InvalidStateException

at line 374
array getOptions()

Returns all session options.

Return Value

array

at line 442
Session setExpiration($time)

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

Parameters

$time

Return Value

Session

at line 468
Session setCookieParameters($path, $domain = null, $secure = null, $samesite = null)

Sets the session cookie parameters.

Parameters

$path
$domain
$secure
$samesite

Return Value

Session

at line 483
array getCookieParameters()

Returns the session cookie parameters.

Return Value

array

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

at line 493
Session setSavePath($path)

Sets path of the directory used to save session data.

Parameters

$path

Return Value

Session

at line 505
Session setStorage(ISessionStorage $storage) deprecated

deprecated use setHandler().

No description

Parameters

ISessionStorage $storage

Return Value

Session

at line 522
Session setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Parameters

SessionHandlerInterface $handler

Return Value

Session

Traits

SmartObject