Class JSession

Description

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.

This class has many influences from the PEAR HTTP_Session module

Located in /application/environment/session.php (line 37)


	
			
Method Summary
 void clear ()
 void destroy ()
 mixed &get (string $name, [mixed $default = null])
 mixed &getLocal (string $name, [mixed $default = null])
 string id ([string $id = null])
 boolean isExpired ()
 boolean isIdle ()
 boolean isNew ()
 string localName ([string $name = null])
 string name ([string $name = null])
 void pause ()
 void register (string $name)
 integer sessionValidThru ()
 mixed set (string $name, mixed $value)
 void setExpire (integer $time, [bool $add = false])
 boolean setGcMaxLifetime ([boolean $gcMaxLifetime = null])
 boolean setGcProbability ([boolean $gcProbability = null])
 void setIdle (integer $time)
 mixed setLocal (string $name, mixed $value)
 void start ([$name $name = 'SessionID'], [$id $id = null])
 void unregister (string $name)
 void updateIdle ()
 boolean useCookies ([boolean $useCookies = null])
 boolean useTransSID ([boolean $useTransSID = null])
 string _detectID ()
Methods
clear (line 129)

Free all session variables

  • access: public
  • static:
  • todo: TODO Save expire and idle timestamps?
void clear ()
destroy (line 110)

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.

void destroy ()
get (line 348)

Returns session variable

  • return: Value of a variable
  • access: public
  • static:
mixed &get (string $name, [mixed $default = null])
  • string $name: Name of a variable
  • mixed $default: Default value of a variable if not set
getLocal (line 388)

Returns local variable of a script

Two scripts can have local variables with the same names

  • return: Value of a local variable
  • access: public
  • static:
mixed &getLocal (string $name, [mixed $default = null])
  • string $name: Name of a variable
  • mixed $default: Default value of a variable if not set
id (line 159)

Sets new ID of a session

  • return: Previous ID of a session
  • see: session_id()
  • access: public
  • static:
string id ([string $id = null])
  • string $id: New ID of a sesion
isExpired (line 229)

Check if session is expired

  • access: public
  • static:
boolean isExpired ()
isIdle (line 245)

Check if session is idle

  • access: public
  • static:
boolean isIdle ()
isNew (line 300)

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 JSession::start() method.

  • return: true if the session was created with the current request, false otherwise
  • access: public
  • static:
boolean isNew ()
localName (line 433)

Sets new local name

  • return: Previous local name
  • access: public
  • static:
string localName ([string $name = null])
  • string $name: New local name
name (line 145)

Sets new name of a session

  • return: Previous name of a session
  • see: session_name()
  • access: public
  • static:
string name ([string $name = null])
  • string $name: New name of a sesion
pause (line 89)

Writes session data and ends session

Session data is usually stored after your script terminated without the need to call JSession::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.

void pause ()
register (line 320)

Register variable with the current session

void register (string $name)
  • string $name: Name of a global variable
sessionValidThru (line 213)

Returns the time up to the session is valid

  • return: Time when the session idles
  • access: public
  • static:
integer sessionValidThru ()
set (line 364)

Sets session variable

  • return: Old value of a variable
  • access: public
mixed set (string $name, mixed $value)
  • string $name: Name of a variable
  • mixed $value: Value of a variable
setExpire (line 173)

Sets the maximum expire time

  • access: public
  • static:
void setExpire (integer $time, [bool $add = false])
  • integer $time: Time in seconds
  • bool $add: Add time to current expire time or not
setGcMaxLifetime (line 476)

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

  • return: The previous value of the property
  • access: public
  • static:
boolean setGcMaxLifetime ([boolean $gcMaxLifetime = null])
  • boolean $gcMaxLifetime: If specified it will replace the previous value of this property
setGcProbability (line 499)

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

  • return: The previous value of the property
  • access: public
  • static:
boolean setGcProbability ([boolean $gcProbability = null])
  • boolean $gcProbability: If specified it will replace the previous value of this property
setIdle (line 201)

Sets the maximum idle time

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

  • access: public
  • static:
void setIdle (integer $time)
  • integer $time: Time in seconds
setLocal (line 410)

Sets local variable of a script.

Two scripts can have local variables with the same names.

  • return: Old value of a local variable
  • access: public
  • static:
mixed setLocal (string $name, mixed $value)
  • string $name: Name of a local variable
  • mixed $value: Value of a local variable
start (line 57)

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.

void start ([$name $name = 'SessionID'], [$id $id = null])
  • $name $name: string Name of a session, default is 'SessionID'
  • $id $id: string Id of a session which will be used only when the session is new
unregister (line 334)

Unregister a variable from the current session

void unregister (string $name)
  • string $name: Name of a global variable
updateIdle (line 261)

Updates the idletime

  • access: public
  • static:
void updateIdle ()
useCookies (line 279)

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

  • return: The previous value of the property
  • access: public
  • static:
boolean useCookies ([boolean $useCookies = null])
  • boolean $useCookies: If specified it will replace the previous value of this property
useTransSID (line 455)

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

  • return: The previous value of the property
  • access: public
  • static:
boolean useTransSID ([boolean $useTransSID = null])
  • boolean $useTransSID: If specified it will replace the previous value of this property
_detectID (line 515)

Tries to find any session id in $_GET, $_POST or $_COOKIE

  • return: Session ID (if exists) or null
  • access: private
  • static:
string _detectID ()

Documentation generated on Sat, 4 Feb 2006 14:26:32 +0100 by phpDocumentor 1.3.0RC4