PHP Class WP_Session, wp-session-manager

Since: 3.6.0
Inheritance: implements ArrayAccess, implements Iterator, implements Countable
Afficher le fichier Open project: ericmann/wp-session-manager Class Usage Examples

Méthodes publiques

Свойство Type Description
$session_id string ID of the current session.

Protected Properties

Свойство Type Description
$exp_variant integer Unix timestamp indicating when the expiration time needs to be reset.
$expires integer Unix timestamp when session expires.

Méthodes publiques

Méthode Description
cache_expiration ( ) : integer Return the read-only cache expiration value.
get_instance ( ) : boolean | WP_Session Retrieve the current session instance.
json_in ( string $data ) : boolean Decodes a JSON string and, if the object is an array, overwrites the session container with its contents.
json_out ( ) : string Output the current container contents as a JSON-encoded string.
regenerate_id ( boolean $delete_old = false ) Regenerate the current session's ID.
reset ( ) Flushes all session variables.
session_started ( ) : boolean Check if a session has been initialized.
write_data ( ) Write the data from the current session to the data storage system.

Méthodes protégées

Méthode Description
__construct ( ) Default constructor.
read_data ( ) : array Read data from a transient for the current session.
set_cookie ( ) Set the session cookie
set_expiration ( ) Set both the expiration time and the expiration variant.

Method Details

__construct() protected méthode

Will rebuild the session collection from the given session ID if it exists. Otherwise, will create a new session with that ID.
protected __construct ( )

cache_expiration() public méthode

Return the read-only cache expiration value.
public cache_expiration ( ) : integer
Résultat integer

get_instance() public static méthode

Retrieve the current session instance.
public static get_instance ( ) : boolean | WP_Session
Résultat boolean | WP_Session

json_in() public méthode

Decodes a JSON string and, if the object is an array, overwrites the session container with its contents.
public json_in ( string $data ) : boolean
$data string
Résultat boolean

json_out() public méthode

Output the current container contents as a JSON-encoded string.
public json_out ( ) : string
Résultat string

read_data() protected méthode

Automatically resets the expiration time for the session transient to some time in the future.
protected read_data ( ) : array
Résultat array

regenerate_id() public méthode

Regenerate the current session's ID.
public regenerate_id ( boolean $delete_old = false )
$delete_old boolean Flag whether or not to delete the old session data from the server.

reset() public méthode

Flushes all session variables.
public reset ( )

session_started() public méthode

Check if a session has been initialized.
public session_started ( ) : boolean
Résultat boolean

set_expiration() protected méthode

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.
protected set_expiration ( )

write_data() public méthode

Write the data from the current session to the data storage system.
public write_data ( )

Property Details

$exp_variant protected_oe property

Unix timestamp indicating when the expiration time needs to be reset.
protected int $exp_variant
Résultat integer

$expires protected_oe property

Unix timestamp when session expires.
protected int $expires
Résultat integer

$session_id public_oe property

ID of the current session.
public string $session_id
Résultat string