-
Notifications
You must be signed in to change notification settings - Fork 1
Using the Session Manager Object
mattbasta edited this page Sep 14, 2011
·
1 revision
The session manager is completely automatic. A session is automatically created the first time a user accesses the site.
Sessions are composed of the following parameters, hashed together:
- The user's IP address (to mitigate session hijacking)
- A randomly generated value
- A secret value kept in the constants file
In most contexts, a variable called $session is created. Setting any property of this object will store that data in the session. Accessing will retrieve the data from the session. If a property doesn't exist, it will return false.
if(!$session->shown) {
echo "Hello! This is the first request of your session.";
$session->shown = true;
}
To close a session, call the $session->destroy() method.
- IXG_KV_SESSIONS
- Setting this value to
falsewill use the PHP session handler instead of the Interchange session handler. The$sessionvariable will simply act as a$_SESSIONwrapper. Using the Interchange session handler allows sessions to persist across multiple server instances that are serviced by a load balancer (by using a common key value store). - IXG_KV_SESSIONS_TIMEOUT
- A timeout value to expire keys after. This should be set to the lifespan of a session.
In a library, define the constant NOSESSION. Once this constant is defined, a session will not be instantiated. This can also be done from the constants file.