Provides access to session-state values as well as session-level settings and lifetime management methods. Based on the standart PHP session handling mechanism it provides for you more advanced features such as database container, idle and expire timeouts, etc.
Expample 1:
// Setting some options and detecting of a new session
HTTP_Session::setCookieless(false);
HTTP_Session::start('MySessionID');
HTTP_Session::set('variable', 'Tet string');
if (HTTP_Session::isNew()) {
echo('new session was created with the current request');
$visitors++; // Increase visitors count
}
Example 2:
// Using database container
HTTP_Session::setContainer('DB');
HTTP_Session::start();
Example 3:
// Setting timeouts
HTTP_Session::start();
HTTP_Session::setExpire(time() + 60 * 60); // expires in one hour
HTTP_Session::setIdle(10 * 60); // idles in ten minutes
Frees all session variables and destroys all data registered to a session
This method resets the $_SESSION variable and destroys all of the data associated with the current session in its storage (file or DB). It forces new session to be started after this method is called. It does not unset the session cookie.
Session data is usually stored after your script terminated without the need to call HTTP_Session::stop(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.
Sets the user-defined session storage functions which are used for storing and retrieving data associated with a session. This is most useful when a storage method other than those supplied by PHP sessions is preferred. i.e. Storing the session data in a local database.
Creates a session (or resumes the current one based on the session id being passed via a GET variable or a cookie). You can provide your own name and/or id for a session.