Introducing WP_Session:
Example :
global $wp_session;
$wp_session['user_name'] = 'User Name'; // A string
$wp_session['user_contact'] = array( 'email' => 'user@name.com' );// An array
$wp_session['user_obj'] = new WP_User( 1 ); // An object
Wordpress session functions:
- wp_session_cache_expire() – get the session expiration time
- wp_session_commit() – write session data out to the transient
- wp_session_decode() – load data into the session from a serialized string
- wp_session_encode() – write session data out to a serialized string
- wp_session_regenerate_id() – change the ID of the current session to a new, random one
- wp_session_start() – start the session and load data based on the user’s cookie
- wp_session_status() – check the status of the current session
- wp_session_unset() – clear out all variables in the current session
- wp_session_write_close() – write session data and end session.