Session
class Session
Provides access to session sections as well as session settings and management methods.
Constants
| private DefaultFileLifetime |
Default server-side idle timeout |
| private SecurityOptions |
|
Properties
| $onStart | |||
| $onBeforeWrite |
Methods
Starts and initializes session data.
No description
No description
Checks whether the session has been started.
Ends the current session and store session data.
Destroys all data registered to a session.
Does session exist for the current request?
Regenerates the session ID.
Returns the current session ID. Avoid relying on the value - it may change between requests.
Gets the session name.
Returns specified session section.
Checks if a session section exist and is not empty.
Returns the names of all existing session sections.
Sets session options.
Returns all session options.
Sets the session lifetime as a time string (e.g. '20 minutes'), or null to revert to the default (a 3-hour server-side idle timeout; the session cookie itself is kept by the browser per its own policy).
Sets the session cookie parameters.
Sets path of the directory used to save session data.
Details
at line 67
void
start()
Starts and initializes session data.
at line 123
void
autoStart(bool $forWrite)
| internal |
No description
at line 179
__destruct()
No description
at line 188
bool
isStarted()
Checks whether the session has been started.
at line 197
void
close()
Ends the current session and store session data.
at line 210
void
destroy()
Destroys all data registered to a session.
at line 230
bool
exists()
Does session exist for the current request?
at line 241
void
regenerateId()
Regenerates the session ID.
at line 264
string
getId()
Returns the current session ID. Avoid relying on the value - it may change between requests.
at line 273
Session
setName(string $name)
Sets the session name.
at line 289
string
getName()
Gets the session name.
at line 304
SessionSection
getSection(string $section, string $class = SessionSection::class)
Returns specified session section.
at line 313
bool
hasSection(string $section)
Checks if a session section exist and is not empty.
at line 327
array
getSectionNames()
Returns the names of all existing session sections.
at line 380
Session
setOptions(array $options)
Sets session options.
at line 429
array
getOptions()
Returns all session options.
at line 486
Session
setExpiration(string|null $expire)
Sets the session lifetime as a time string (e.g. '20 minutes'), or null to revert to the default (a 3-hour server-side idle timeout; the session cookie itself is kept by the browser per its own policy).
at line 508
Session
setCookieParameters(string $path, string|null $domain = null, bool|null $secure = null, SameSite|string|null $sameSite = null)
Sets the session cookie parameters.
at line 527
Session
setSavePath(string $path)
Sets path of the directory used to save session data.
at line 538
Session
setHandler(SessionHandlerInterface $handler)
Sets user session handler.