Private Method Details |
&Bs_SimpleSession |
|
private void &Bs_SimpleSession( )
|
| |
Constructor.
There is no need to use this contructor. Please use the instance as follows$session =& $GLOBALS['Bs_SimpleSession']; (instead of $session =& new Bs_SimpleSession() )@pattern singleton
|
| Returns |
void |
|
start |
|
private bool start( )
|
| |
Starts up session.
There is no need to call this function as Bs_SimpleSession is started the momentit's included (if not running already).
|
| Returns |
bool TRUE if succes, FALSE otherwise. |
|
register |
|
private void register( string $key, string &$value, [ string $sessName ] )
|
| |
Register a var to the session
by passing a unique key, the var and an optional session name.Behaver of this function:o If the passed key is *not* registered, the passed value is taken as default.o If the passed key is registered, the session value will overwrite the passed value(tis is possible because it's passed by reference)o From the moment you call register, that value is 'watched' (by holding a pointer to it).That means that any change to that value will be stored at the request end and availableat the next request.Sample I "Simple Counter":include_once($APP['path']['core'] . 'net/http/Bs_SimpleSession.class.php');$session =& $GLOBALS['Bs_SimpleSession']; // Use the per ref operator '=&' <-- !!$counter=0;if (!$session->register('my_counter', $counter)) echo $session->getLastError();echo $counter++ . "<br>";Sample II "Parallel Session":# TIP: If you have a lot of session data that is not needed on every request, then# you may want to use following technique (called parallel sessions)# In this manner the $bigDataRec will only be loaded when needed and not on everyinclude_once($APP['path']['core'] . 'net/http/Bs_SimpleSession.class.php');$session =& $GLOBALS['Bs_SimpleSession']; // Use the per ref operator '=&' <-- !!$smallDataRec = NULL; // Data used in ever session$bigDataRec = NULL; // Data not used in ever session$session->register('my_sessionData', $smallDataRec);if ($needThatBigData) {$session->register('my_bigData', $bigDataRec, 'myBigDataSession');// do something with the $bigDataRec}// do something with the $smallDataWARNING: Never add session values that reference themselfs in a cyclic way.PHP 4.x cycles 7 time and then ends. This will lead to unwanted results.E.g. $a = array(); $a[0] = &$a;Will become array(array(array(array(array(array(array()))))))Array of array, depth 7
|
| Parameter |
|
| string |
$key |
|
|
(to identify the value) |
|
|
| string |
&$value |
|
|
(*by reference*) |
|
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
void |
| See Also |
register() |
|
unRegister |
|
private void unRegister( string $key, [ string $sessName ] )
|
| |
Remove a var from the session register list
|
| Parameter |
|
| string |
$key |
|
|
(to identify the value) |
|
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
void |
|
isRegistered |
|
private bool isRegistered( string $key, [ string $sessName ] )
|
| |
Tells if the var is registered.
The session-data with name == $sessName is loaded (if not loaded already)and checks if passed $key has a session value.TIP: Call only when you plan to use and/or modify a session var.This will improve the performance by omitting the file load.
|
| Parameter |
|
| string |
$key |
|
|
(to identify the value) |
|
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
bool |
|
&getVar |
|
private mixed &getVar( string $key, [ string $sessName ] )
|
| |
Returns the value of a registered var.
NOTE: You will normaly not be using this function. Instead you'll be using register().Examples:To get the data by value, do $val = getVar('someVar'); // Gives you a copyTo get the data by reference, do $ref = &getVar('someVar');
|
| Parameter |
|
| string |
$key |
|
|
(to identify the value) |
|
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
mixed |
| Throws |
NULL if not found of failer. |
|
destroy |
|
private bool destroy( [ string $sessName ] )
|
| |
Destroys all data of a session by removing the data.
|
| Parameter |
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
bool always TRUE. |
|
reset |
|
private bool reset( [ string $sessName ] )
|
| |
Reset the session data. All data is lost but session properties remain
|
| Parameter |
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
bool always TRUE. |
|
setProperty |
|
private void setProperty( array $prop, [ string $sessName ] )
|
| |
Set a new property for a session.
You may pass a property hash with following parameters. All are optionaland if omitet the default will be taken.$prop = array ('path' => "", // <- Path to where to store the session files.'maxStandbyTime' => 30, // <- How long should the session stay valid (in min) if *not* used. 0 means until browser end.'maxLifeTime' => 300, // <- Independent of use, invalidat after this time (im min). 0 means until browser end.);NOTE: 'maxLifeTime' is limited by PHP's 'session.cookie_lifetime' that we can not exceed ifcookies are used.PHP writes: "session.cookie_lifetime specifies the lifetime of the cookie in seconds which issent to the browser. The value 0 means "until the browser is closed." Default is 0."So session.cookie_lifetime == 0 is OK.
|
| Parameter |
|
|
|
| string |
$sessName |
= >>'default'<< |
|
(Optional, default is 'default'). Only used for parallel sessions. |
|
| Returns |
void |
|
getSid |
|
private void getSid( )
|
| |
Returns the session id for the current session.
|
| Returns |
void |
|
getLastError |
|
private void getLastError( )
|
| |
Returns the last error string.
|
| Returns |
void |
|
write_close |
|
private void write_close( )
|
| |
'Manually' store all session date to file.
Session data is atomatically stored after your script terminated without the need to call write_close(),but because we write the session-data with exclusive locks to prevent concurrent writes on the samefile this leads to a new behaver when sing framesets together with sessions. You will experiencethe frames loading one by one due to this locking. You can reduce the time needed to load allthe frames by ending the session as soon as all changes to session variables are done by callingwrite_close().
|
| Returns |
void |
|
_init |
|
private void _init( $sessName )
|
| |
Internal init of a session.
Called at varius places in this code to insure that everthing has been set up OK.That's way we have to buffer the state.1) If already called befor, return the same state.2) If PHP session_start() hasn't been started, start now.3) If session with name '$sessName' is unknown, setup new session and GOTO END with status TRUE4) If PHP sources changed ('version') destroy and setup new session5) Check if a garbage collector need to start.6) If 'maxLifeTime' or 'maxStandbyTime' timed out GOTO END with status FALSE7) Try to fetch the session data form file. If we fail GOTO END with status FALSEEND)If status==TRUE : Update 'accessTime'.If status==FALSE: Try to destroy any old session andsetup a new one. Setup status is new status.Do: a) First try to fetch any valid session matches the session name.Dedata that check if a SID is already set and
|
| Parameter |
|
|
$sessName |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_fetch |
|
private void _fetch( $sessName )
|
| |
Fetch the data belonging to this session from the source.
|
| Parameter |
|
|
$sessName |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_copyProp |
|
private void _copyProp( $fromProp, &$toProp )
|
| |
Copy property values from $fromProp to $toProp and do some checks
|
| Parameter |
|
|
$fromProp |
|
|
Warning: documentation is missing. |
|
|
|
&$toProp |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_pathCheck |
|
private void _pathCheck( &$path )
|
| |
Standardize the passed path and check for existens and accessability.
Trigger a PHP E_USER_WARNING on failer!
|
| Parameter |
|
|
&$path |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|
_setup |
|
private void _setup( $sessName )
|
| |
Warning: documentation is missing.
|
| Parameter |
|
|
$sessName |
|
|
Warning: documentation is missing. |
|
| Returns |
void |
|