Class: SessionStore
- Package: saf.Session
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 1.0, 2002-11-09, $Id: Store.php,v 1.3 2007/10/06 00:06:30 lux Exp $
- Access: public
This is the base store driver package for saf.Session. Custom
drivers are created by sub-classing this package.
Usage Example
<?php
$s = new SessionStore;
$s->setProperties (array (
'foo' => 'bar',
));
if ($s->start ($id)) {
// connected
// set a few session variables
$s->set ('name', 'Joe');
$s->set ('age', '24');
// get the value of 'name'
$name =$s->get ('name');
// rename 'name'
$oldname = $s->set ('name', 'Jack');
// unset 'age'
$s->set ('age', false);
// remember these for next time
$s->save ();
} else {
// not connected
echo $s->error;
}
?>
Properties
$access = array ()
$status = array ()
$roles = array ()
$teams = array ()
$resources = array ()
$user = array ()
$prefs = array ()
$_prefs = array ()
$path
$realm
$cancelmessage = 'You do not have permission to access this resource.'
$cookiename = 'sitellite_session_id'
- Access: public
Name of the cookie. Defaults to 'sitellite_session_id'.
$cookieexpires = false
- Access: public
The lifetime of the session cookie.
$cookiedomain = ''
- Access: public
Domain value of the cookie.
$cookiepath = '/'
- Access: public
Path value of the cookie. Defaults to '/'.
$cookiesecure = 0
- Access: public
If 1 then the cookie will only be sent over secure connections.
$usernamefield = 'username'
- Access: public
The name of the username field in the form (uses saf.MailForm)
created by sendAuthRequest(). Defaults to 'username'.
$passwordfield = 'password'
- Access: public
The name of the password field in the form
created by sendAuthRequest(). Defaults to 'password'.
$hiddenfields = array ()
- Access: public
A list of hidden form fields and their values.
$usernametext = 'Username'
- Access: public
The alt text of the username field in the form
created by sendAuthRequest(). Defaults to 'Username'.
$passwordtext = 'Password'
- Access: public
The alt text of the password field in the form
created by sendAuthRequest(). Defaults to 'Password'.
$submittext = 'Sign In'
- Access: public
The alt text of the submit button in the form
created by sendAuthRequest(). Defaults to 'Sign In'.
$formtemplate = false
- Access: public
The template of the form created by sendAuthRequest().
Defaults to false (no template).
$usernamerules = array ()
- Access: public
A list of rules for the username form field. The keys are
the rules and the values are the invalid messages.
$passwordrules = array ()
- Access: public
A list of rules for the password form field. The keys are
the rules and the values are the invalid messages.
$formmessage = 'Please enter your username and password.'
- Access: public
The welcome message of the form. Defaults to
'Please enter your username and password.'
$invalidmessage = 'Sorry, the password you specified was invalid. Please try again.'
- Access: public
The invalid message of the form. Defaults to
'Sorry, the password you specified was invalid. Please try again.'
$timeoutmessage = 'Sorry, your session has timed out. Please sign in again to continue.'
- Access: public
The timeout message of the form. Defaults to
'Sorry, your session has timed out. Please sign in again to continue.'
$sessObj
- Access: public
A reference to the main session object, in case it's
needed by a specific handler.
$error
- Access: public
The error message if an error occurs.
$total
Number of users.
$dir = 'inc/conf/auth/roles'
Directory to store info.
$data = array ()
Parsed data from file.
$file = 'inc/conf/auth/resources/index.php'
File to store resource info.
$id
- Access: public
The session id value.
$valid = false
- Access: public
Says whether this session is valid.
$username
- Access: public
Contains the username of the user.
$password
- Access: public
Contains the password of the user.
$useID = true
- Access: public
Specifies whether or not to use a session id. Some handlers or
sources may not support session ids (ie. the Basic handler), and so they
may be disabled.
$timeout = 3600
- Access: public
Specifies a length in seconds that the session may be inactive
for before automatically logging the user out. This is also optional,
as some handlers or sources may not support it.
$autoSave = true
- Access: public
Specifies whether calls to set() should also call save()
automatically. Defaults to true, since for most intents and purposes
this is a nice way of not having to think about it.
$handler
- Access: public
The handler driver object.
$source
- Access: public
The source driver object.
$store
- Access: public
The store driver object.
$tablename = 'sitellite_user'
- Access: public
The name of the database table that contains the users.
Defaults to 'sitellite_user'.
$usernamecolumn = 'username'
- Access: public
The name of the username column in the database.
Defaults to 'username'.
$passwordcolumn = 'password'
- Access: public
The name of the password column in the database.
Defaults to 'password'.
$sessionidcolumn = 'session_id'
- Access: public
The name of the session id column in the database.
Defaults to 'session_id'.
$timeoutcolumn = 'expires'
- Access: public
The name of the timeout column in the database.
Defaults to 'expires'.
$rolecolumn = 'role'
- Access: public
The name of the role column in the database.
Defaults to 'role'.
$teamcolumn = 'team'
- Access: public
The name of the team column in the database.
Defaults to 'team'.
$teamscolumn = 'teams'
- Access: public
The name of the teams column in the database.
Defaults to 'team'.
$disabledcolumn = 'disabled'
- Access: public
The name of the disabled column in the database.
Defaults to 'disabled'.
$publiccolumn = 'public'
- Access: public
The name of the public column in the database.
Defaults to 'public'.
$encryptionMethod = 'better_crypt_compare'
- Access: public
The method to use to compare the password to the
encrypted copy from the source. Defaults to
'better_crypt_compare', which uses a modification of the
crypt() function. $encryptionMethod must be any valid
value that can be passed as a first parameter to the
call_user_func() PHP function. The specified function
must accept the challenging password as a first parameter,
and the source password as a second. This makes it easy
to write alternate encryption methods, such as MD5.
$session_table = 'sitellite_user_session'
- Access: public
The table for the session id storage, must use the same field
names as the main table for username, sessionid and timeout.
$resultObj
- Access: public
An object containing all of the values returned from
the data source regarding the user.
$map = array ()
- Access: public
Source fields to map to the specified fields.
$set = array ()
- Access: public
User values to set automatically to the specified values.
$readOnly = false
- Access: public
If this is set to true, the session source is considered "read-only"
and can't be modified via Sitellite's user administration capabilities.
$session_name = 'sitellite_session_id'
- Access: public
The error message if an error occurs. Defaults to
'sitellite_session_id'.
$connection = false
- Access: public
The store connection resource, if applicable to the individual
driver.
$_values = array ()
- Access: private
The volatile (as in not stored yet) list of values in the
data store.
Methods
SessionStore ()
- Access: public
Constructor method.
setProperties ($properties)
- Access: public
Sets the properties of this object.
start ($id)
- Access: public
- Return: boolean
Starts the session store, initializing any necessary connections,
and retrieving any session values found from a previous web page request.
$id is the session identifier of the current visitor.
get ($name)
- Access: public
- Return: mixed
Retrieves a value from the session store. Returns false if
the value does not exist.
set ($name, $value = false)
- Access: public
- Return: mixed
Sets a value in the session store. If the value is false,
it will unset it in the store. If the value is being unset or
set to a new value, then the old value is returned. If it is a
new value, then the value itself will be returned.
save ()
- Access: public
- Return: boolean
Tells the session store to save the values within it.
close ()
- Access: public
Closes the session with the store, erasing the values
for this session.
