-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
84 lines (50 loc) · 3.69 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
=== Simple Sessions for WordPress ===
Contributors: Kevin Newman, ericmann
Tags: session
Requires at least: 3.4.2
Tested up to: 3.8
Stable tag: 1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Developer friendly session manager for WordPress.
== Description ==
Adds a developer friendly, partitionable, persistent session manager for use in WordPress. Session data is stored in the WordPress Options table. Transients are no good for the purposes of session data, because data is not guaranteed to be available if a cache (such as MemCached on WP Engine) is used to replace the default transient backing store in wp_options.
Simple Sessions provides plugin and theme authors the ability to use WordPress-managed session variables without having to use the standard PHP `$_SESSION` superglobal.
Session partitioning allows a developer to isolate their own session data.
Delayed initialization provides opportunity to make sure serialized classes are available before unserialization occurs.
NOTE: You must construct your session instance before any headers have been sent to the client, since the constructor will send cookie headers.
Simple Sessions is a fork of WP-Session-Manager, by Eric Mann.
== Installation ==
= Manual Installation =
1. Upload the entire `/wp-simple-sessions` folder to the plugins directory (usually `/wp-content/plugins/`) directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Use `WP_SimpleSession::get_instance($partition_id)` in your code.
== Frequently Asked Questions ==
= How do I add session variables? =
First, make a reference to the SimpleSession instance. Then, use the accessors to get and set values:
`$my_session = SimpleSession::factory('user_session');
// set values
$my_session->set('user_name', 'User Name'); // A string
$my_session->set('user_contact', array( 'email' => 'user@name.com' ) ); // An array
$my_session->set('user_obj', new WP_User( 1 ) ); // An object
// get by key later
echo $my_session->get('user_name');
// or get a reference to the storage array
print_r( $my_session->get() ); // returns everything as an array`
= 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`
= What does partionable mean? =
You can have multiple sessions at the same time, each with their own cookie. If you are a plugin or theme developer, you can keep your session data separate from anyone else's. Just pass a unique name to the factory.
= Does the session automatically start? =
Yes and no. There is no global automatic session (use WP Session Manager for that). But SimpleSession does set itself up when you instantiate it using the factory method, or by directly instantiating SimpleSession (recommended to use the factory).
= Why did you fork WP Session Manager? =
Two reasons, one practical and one subjective.
1. I needed to start the session later than WP Session Manager allows. Some of my class files in the theme must be serialized into the session data store are not available when the plugin runs, so WP Session Manager was not restoring my data correctly.
2. I don't like the Class based accessor system thath WP Session Manager uses. I'd rather use set/get methods and/or have direct access to the storage array. This is more like dealing with a regular PHP array.
== Screenshots ==
None
== Changelog ==
= 1.0 =
* Initial fork from WP Session Manager (v1.1) - many major chnages. Created SimpleSession.