class Session

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

Constants

private DefaultFileLifetime

Default file lifetime

private SecurityOptions

Properties

$onStart
$onBeforeWrite

Methods

__construct(IRequest $request, IResponse $response)

No description

void
start()

Starts and initializes session data.

void
autoStart(bool $forWrite)

No description

__destruct()

No description

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 exist 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(string $name)

Sets the session name to a specified one.

string
getName()

Gets the session name.

getSection(string $section, string $class = SessionSection::class)

Returns specified session section.

bool
hasSection(string $section)

Checks if a session section exist and is not empty.

array
getSectionNames()

No description

getIterator() deprecated

No description

setOptions(array $options)

Sets session options.

array
getOptions()

Returns all session options.

setExpiration(string|null $expire)

Sets the amount of time (like '20 minutes') allowed between requests before the session will be terminated, null means "for a maximum of 3 hours or until the browser is closed".

setCookieParameters(string $path, string|null $domain = null, bool|null $secure = null, string|null $sameSite = null)

Sets the session cookie parameters.

array
getCookieParameters() deprecated

No description

setSavePath(string $path)

Sets path of the directory used to save session data.

setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Details

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

No description

Parameters

IRequest $request
IResponse $response

at line 86
void start()

Starts and initializes session data.

Return Value

void

Exceptions

InvalidStateException

at line 142
void autoStart(bool $forWrite)

internal  
 

No description

Parameters

bool $forWrite

Return Value

void

at line 198
__destruct()

No description

at line 207
bool isStarted()

Has been session started?

Return Value

bool

at line 216
void close()

Ends the current session and store session data.

Return Value

void

at line 229
void destroy()

Destroys all data registered to a session.

Return Value

void

at line 249
bool exists()

Does session exist for the current request?

Return Value

bool

at line 260
void regenerateId()

Regenerates the session ID.

Return Value

void

Exceptions

InvalidStateException

at line 283
string getId()

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

Return Value

string

at line 293
Session setName(string $name)

Sets the session name to a specified one.

Parameters

string $name

Return Value

Session

at line 309
string getName()

Gets the session name.

Return Value

string

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

Returns specified session section.

Parameters

string $section
string $class

Return Value

SessionSection

Exceptions

InvalidArgumentException

at line 331
bool hasSection(string $section)

Checks if a session section exist and is not empty.

Parameters

string $section

Return Value

bool

at line 342
array getSectionNames()

No description

Return Value

array

at line 353
Iterator getIterator() deprecated

deprecated use getSectionNames()

No description

Return Value

Iterator

at line 389
Session setOptions(array $options)

Sets session options.

Parameters

array $options

Return Value

Session

Exceptions

NotSupportedException
InvalidStateException

at line 437
array getOptions()

Returns all session options.

Return Value

array

at line 504
Session setExpiration(string|null $expire)

Sets the amount of time (like '20 minutes') allowed between requests before the session will be terminated, null means "for a maximum of 3 hours or until the browser is closed".

Parameters

string|null $expire

Return Value

Session

at line 526
Session setCookieParameters(string $path, string|null $domain = null, bool|null $secure = null, string|null $sameSite = null)

Sets the session cookie parameters.

Parameters

string $path
string|null $domain
bool|null $secure
string|null $sameSite

Return Value

Session

at line 542
array getCookieParameters() deprecated

deprecated

No description

Return Value

array

at line 553
Session setSavePath(string $path)

Sets path of the directory used to save session data.

Parameters

string $path

Return Value

Session

at line 565
Session setHandler(SessionHandlerInterface $handler)

Sets user session handler.

Parameters

SessionHandlerInterface $handler

Return Value

Session

Traits

SmartObject