WordPress.org

Ready to get started?Download WordPress

Plugin Directory

WP Session Manager

Prototype session management for WordPress.

How do I add session variables?

First, make a reference to the WP_Session instance. Then, use it like an associative array, just like $_SESSION:

$wp_session = WP_Session::get_instance();
$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

How long do session variables live?

By default, session variables will live for 24 minutes from the last time they were accessed - either read or write.

This value can be changed by using the wp_session_expiration filter:

add_filter( 'wp_session_expiration', function() { return 60 * 60; } ); // Set expiration to 1 hour

Requires: 3.4.2 or higher
Compatible up to: 3.8.3
Last Updated: 2013-12-18
Downloads: 4,487

Ratings

5 stars
5 out of 5 stars

Support

1 of 2 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,1,1
100,1,1
100,1,1