final | |
|---|---|
extends |
Recursive_ArrayAccess |
implements |
Iterator, Countable |
WordPress Session class for managing user session data.
| Since | |
|---|---|
3.7.0 |
|
| Methods | ||||||
|---|---|---|---|---|---|---|
public
static
|
get_instance(): bool|WP_Session
Retrieve the current session instance.
Retrieve the current session instance. |
# | ||||
protected
|
__construct()
Default constructor.
Will rebuild the session collection from the given session ID if it exists. Otherwise, will
create…
Default constructor. Will rebuild the session collection from the given session ID if it exists. Otherwise, will create a new session with that ID. Since
Overrides |
# | ||||
protected
|
get_session_delimiter(string $delimiter = '||')
Session delimiter. Provides filter to change the default || delimiter.
Session delimiter. Provides filter to change the default || delimiter. A notice for session might appear when we switch delimiter while already a cookie is set, That's because new delimiter tries to explode session cookies saved using old delimiter. Parameters
Since
|
# | ||||
protected
|
set_expiration()
Set both the expiration time and the expiration variant.
Set both the expiration time and the expiration variant. If the current time is below the variant, we don't update the session's expiration time. If it's greater than the variant, then we update the expiration time in the database. This prevents writing to the database on every page load for active sessions and only updates the expiration time if we're nearing when the session actually expires. By default, the expiration time is set to 30 minutes. By default, the expiration variant is set to 24 minutes. As a result, the session expiration time - at a maximum - will only be written to the database once every 24 minutes. After 30 minutes, the session will have been expired. No cookie will be sent by the browser, and the old session will be queued for deletion by the garbage collector. Since
|
# | ||||
protected
|
set_cookie()
Set the session cookie
Set the session cookie Since
|
# | ||||
protected
|
generate_id(): string
Generate a cryptographically strong unique ID for the session token.
Generate a cryptographically strong unique ID for the session token. |
# | ||||
protected
|
is_valid_md5(string $md5 = ''): int
Checks if is valid md5 string
Checks if is valid md5 string Parameters
|
# | ||||
protected
|
read_data(): array
Read data from a transient for the current session.
Read data from a transient for the current session. Automatically resets the expiration time for the session transient to some time in the future. |
# | ||||
public
|
write_data()
Write the data from the current session to the data storage system.
Write the data from the current session to the data storage system. |
# | ||||
public
|
json_out(): string
Output the current container contents as a JSON-encoded string.
Output the current container contents as a JSON-encoded string. Since
|
# | ||||
public
|
json_in(string $data): bool
Decodes a JSON string and, if the object is an array, overwrites the session container with its contents.
Decodes a JSON string and, if the object is an array, overwrites the session container with its contents. Parameters
|
# | ||||
public
|
regenerate_id(bool $delete_old = false)
Regenerate the current session's ID.
Regenerate the current session's ID. Parameters
|
# | ||||
public
|
session_started(): bool
Check if a session has been initialized.
Check if a session has been initialized. |
# | ||||
public
|
cache_expiration(): int
Return the read-only cache expiration value.
Return the read-only cache expiration value. |
# | ||||
public
|
reset()
Flushes all session variables.
Flushes all session variables. |
# | ||||
public
|
current(): mixed
Current position of the array.
|
# | ||||
public
|
key(): mixed
Key of the current element.
|
# | ||||
public
|
next(): void
Move the internal point of the container array to the next item
|
# | ||||
public
|
rewind(): void
Rewind the internal point of the container array.
|
# | ||||
public
|
valid(): bool
Is the current key valid?
|
# | ||||
public
|
count(): int
Get the count of elements in the container array.
|
# | ||||
| Methods inherited from Recursive_ArrayAccess |
|---|
__clone(), toArray(), offsetExists(), offsetGet(), offsetSet(), offsetUnset() |
| Properties | |||
|---|---|---|---|
public
|
string
|
$session_id
|
# |
protected
|
int
|
$expires
|
# |
protected
|
int
|
$exp_variant
|
# |
| Properties inherited from Recursive_ArrayAccess |
|---|
$container, $dirty |