Session
class Session
Provides access to session sections as well as session settings and management methods.
Constants
private DEFAULT_FILE_LIFETIME |
Default file lifetime |
private SECURITY_OPTIONS |
|
Methods
Starts and initializes session data.
Has been session started?
Ends the current session and store session data.
Destroys all data registered to a session.
Does session exists for the current request?
Regenerates the session ID.
Returns the current session ID. Don't make dependencies, can be changed for each request.
Gets the session name.
Returns specified session section.
Checks if a session section exist and is not empty.
Iteration over all sections.
Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.
Sets session options.
Returns all session options.
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".
Sets the session cookie parameters.
Sets path of the directory used to save session data.
Details
at line 73
void
start()
Starts and initializes session data.
at line 155
bool
isStarted()
Has been session started?
at line 164
void
close()
Ends the current session and store session data.
at line 177
void
destroy()
Destroys all data registered to a session.
at line 196
bool
exists()
Does session exists for the current request?
at line 206
void
regenerateId()
Regenerates the session ID.
at line 226
string
getId()
Returns the current session ID. Don't make dependencies, can be changed for each request.
at line 236
Session
setName(string $name)
Sets the session name to a specified one.
at line 252
string
getName()
Gets the session name.
at line 265
SessionSection
getSection(string $section, string $class = SessionSection::class)
Returns specified session section.
at line 274
bool
hasSection(string $section)
Checks if a session section exist and is not empty.
at line 287
Iterator
getIterator()
Iteration over all sections.
at line 301
void
clean()
internal |
Cleans and minimizes meta structures. This method is called automatically on shutdown, do not call it directly.
at line 325
Session
setOptions(array $options)
Sets session options.
at line 368
array
getOptions()
Returns all session options.
at line 433
Session
setExpiration(string|null $time)
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".
at line 455
Session
setCookieParameters(string $path, string $domain = null, bool $secure = null, string $sameSite = null)
Sets the session cookie parameters.
at line 471
array
getCookieParameters()
deprecated
deprecated
No description
at line 481
Session
setSavePath(string $path)
Sets path of the directory used to save session data.
at line 493
Session
setHandler(SessionHandlerInterface $handler)
Sets user session handler.
Traits
Strict class for better experience.