[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/HTTP_Session/ -> Session.php (summary)

Class for managing HTTP sessions 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.

Author: David Costa <[email protected]>
Author: Michael Metz <[email protected]>
Author: Stefan Neufeind <[email protected]>
Author: Torsten Roehr <[email protected]>
Copyright: 1997-2005 The PHP Group
License: http://www.php.net/license/3_0.txt PHP License 3.0
Version: CVS: $Id: Session.php,v 1.15 2007/07/14 12:11:54 troehr Exp $
File Size: 804 lines (23 kb)
Included or required: 5 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

HTTP_Session:: (33 methods):
  setContainer()
  start()
  pause()
  destroy()
  regenerateId()
  replicate()
  clear()
  detectID()
  name()
  id()
  setExpire()
  setIdle()
  sessionValidThru()
  isExpired()
  isIdle()
  updateIdle()
  useCookies()
  isNew()
  register()
  unregister()
  registered()
  get()
  getRef()
  set()
  setRef()
  is_set()
  getLocal()
  setLocal()
  localName()
  _init()
  useTransSID()
  setGcMaxLifetime()
  setGcProbability()


Class: HTTP_Session  - X-Ref

Class for managing HTTP sessions

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.

Example 1:

<code>
// 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
}

//HTTP_Session::regenerateId();
</code>

Example 2:

<code>
// Using database container
HTTP_Session::setContainer('DB');
HTTP_Session::start();
</code>

Example 3:

<code>
// Setting timeouts
HTTP_Session::start();
HTTP_Session::setExpire(time() + 60 * 60); // expires in one hour
HTTP_Session::setIdle(time()+ 10 * 60);    // idles in ten minutes
if (HTTP_Session::isExpired()) {
// expired
echo('Your session is expired!');
HTTP_Session::destroy();
}
if (HTTP_Session::isIdle()) {
// idle
echo('You've been idle for too long!');
HTTP_Session::destroy();
}
HTTP_Session::updateIdle();
</code>

setContainer($container, $container_options = null)   X-Ref
Sets user-defined session storage functions

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.

param: string $container         Container name
param: array  $container_options Container options
return: void

start($name = 'SessionID', $id = null)   X-Ref
Initializes session data

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.

param: string $name string Name of a session, default is 'SessionID'
param: string $id   string Id of a session which will be used
return: void

pause()   X-Ref
Writes session data and ends session

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.

return: void

destroy()   X-Ref
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.

return: void

regenerateId($deleteOldSessionData = false)   X-Ref
Calls session_regenerate_id() if available

param: bool $deleteOldSessionData Whether to delete data of old session
return: bool

replicate($targetTable, $id = null)   X-Ref
This function copies session data of specified id to specified table

param: string $targetTable Table to replicate data to
param: string $id          ID of the session
return: bool

clear()   X-Ref
Free all session variables

return: void

detectID()   X-Ref
Tries to find any session id in $_GET, $_POST or $_COOKIE

return: string Session ID (if exists) or null

name($name = null)   X-Ref
Sets new name of a session

param: string $name New name of a session
return: string Previous name of a session

id($id = null)   X-Ref
Sets new ID of a session

param: string $id New ID of a session
return: string Previous ID of a session

setExpire($time, $add = false)   X-Ref
Sets the maximum expire time

param: integer $time Time in seconds
param: bool    $add  Add time to current expire time or not
return: void

setIdle($time, $add = false)   X-Ref
Sets the maximum idle time

Sets the time-out period allowed
between requests before the session-state
provider terminates the session.

param: int  $time Time in seconds
param: bool $add  Add time to current maximum idle time or not
return: void

sessionValidThru()   X-Ref
Returns the time up to the session is valid

return: integer Time when the session idles

isExpired()   X-Ref
Check if session is expired

return: bool

isIdle()   X-Ref
Check if session is idle

return: bool

updateIdle()   X-Ref
Updates the idletime

return: void

useCookies($useCookies = null)   X-Ref
If optional parameter is specified it indicates
whether the module will use cookies to store
the session id on the client side

It returns the previous value of this property

param: bool $useCookies If specified it will replace the previous value
return: bool The previous value of the property

isNew()   X-Ref
Gets a value indicating whether the session
was created with the current request

You MUST call this method only after you have started
the session with the HTTP_Session::start() method.

return: bool   True if the session was created

register($name)   X-Ref
Register variable with the current session

param: string $name Name of a global variable
return: bool

unregister($name)   X-Ref
Unregister a variable from the current session

param: string $name Name of a global variable
return: bool

registered($name)   X-Ref
Checks if a session variable is registered

param: string $name Variable name
return: bool

get($name, $default = null)   X-Ref
Returns session variable

param: string $name    Name of a variable
param: mixed  $default Default value of a variable if not set
return: mixed  Value of a variable

getRef($name)   X-Ref
Returns session variable by reference

param: string $name Name of a variable
return: mixed  Value of a variable

set($name, $value)   X-Ref
Sets session variable

param: string $name  Name of a variable
param: mixed  $value Value of a variable
return: mixed  Old value of a variable

setRef($name, &$value)   X-Ref
Sets session variable by reference

param: string $name  Name of a variable
param: mixed  $value Value of a variable
return: mixed  Old value of a variable

is_set($name)   X-Ref
Checks if a session variable is set

param: string $name Variable name
return: bool

getLocal($name, $default = null)   X-Ref
Returns local variable of a script

Two scripts can have local variables with the same names

param: string $name    Name of a variable
param: mixed  $default Default value of a variable if not set
return: mixed  Value of a local variable

setLocal($name, $value)   X-Ref
Sets local variable of a script.
Two scripts can have local variables with the same names.

param: string $name  Name of a local variable
param: mixed  $value Value of a local variable
return: mixed  Old value of a local variable

localName($name = null)   X-Ref
Sets new local name

param: string $name New local name
return: string Previous local name

_init()   X-Ref
Initialize

return: void

useTransSID($useTransSID = null)   X-Ref
If optional parameter is specified it indicates
whether the session id will automatically be appended to
all links

It returns the previous value of this property

param: bool $useTransSID If specified it will replace the previous value
return: bool   The previous value of the property

setGcMaxLifetime($gcMaxLifetime = null)   X-Ref
If optional parameter is specified it determines the number of seconds
after which session data will be seen as 'garbage' and cleaned up

It returns the previous value of this property

param: bool $gcMaxLifetime If specified it will replace the previous value
return: bool   The previous value of the property

setGcProbability($gcProbability = null)   X-Ref
If optional parameter is specified it determines the
probability that the gc (garbage collection) routine is started
and session data is cleaned up

It returns the previous value of this property

param: bool $gcProbability If specified it will replace the previous value
return: bool   The previous value of the property



Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1