[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/ -> THttpSession.php (sommaire)

THttpSession class

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: THttpSession.php 1397 2006-09-07 07:55:53Z wei $
Poids: 720 lignes (20 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 3 classes

THttpSession:: (47 méthodes):
  __destruct()
  getID()
  setID()
  init()
  open()
  close()
  destroy()
  getIsStarted()
  getSessionID()
  setSessionID()
  getSessionName()
  setSessionName()
  getSavePath()
  setSavePath()
  getUseCustomStorage()
  setUseCustomStorage()
  getCookie()
  getCookieMode()
  setCookieMode()
  getAutoStart()
  setAutoStart()
  getGCProbability()
  setGCProbability()
  getUseTransparentSessionID()
  setUseTransparentSessionID()
  getTimeout()
  setTimeout()
  _open()
  _close()
  _read()
  _write()
  _destroy()
  _gc()
  getIterator()
  getCount()
  count()
  getKeys()
  itemAt()
  add()
  remove()
  clear()
  contains()
  toArray()
  offsetExists()
  offsetGet()
  offsetSet()
  offsetUnset()

TSessionIterator:: (6 méthodes):
  __construct()
  rewind()
  key()
  current()
  next()
  valid()

THttpSessionCookieMode:: (0 méthodes):


Classe: THttpSession  - X-Ref

THttpSession class

THttpSession provides session-level data management and the related configurations.
To start the session, call {@open}; to complete and send out session data, call {@close};
to destroy the session, call {@destroy}. If AutoStart is true, then the session
will be started once the session module is loaded and initialized.

To access data stored in session, use THttpSession like an associative array. For example,
<code>
$session=new THttpSession;
$session->open();
$value1=$session['name1'];  // get session variable 'name1'
$value2=$session['name2'];  // get session variable 'name2'
foreach($session as $name=>$value) // traverse all session variables
$session['name3']=$value3;  // set session variable 'name3'
</code>

The following configurations are available for session:
{@link setAutoStart AutoStart}, {@link setCookie Cookie},
{@link setCacheLimiter, {@link setSavePath SavePath},
{@link setUseCustomStorage UseCustomStorage}, {@link setGCProbability GCProbability},
{@link setCookieUsage CookieUsage}, {@link setTimeout Timeout}.
See the corresponding setter and getter documentation for more information.
Note, these properties must be set before the session is started.

THttpSession can be inherited with customized session storage method.
Override {@link _open}, {@link _close}, {@link _read}, {@link _write}, {@link _destroy} and {@link _gc}
and set {@link setUseCustomStorage UseCustomStorage} to true.
Then, the session data will be stored using the above methods.

By default, THttpSession is registered with {@link TApplication} as the
request module. It can be accessed via {@link TApplication::getSession()}.

THttpSession may be configured in application configuration file as follows,
<code>
<module id="session" class="THttpSession" SessionName="SSID" SavePath="/tmp"
CookieMode="Allow" UseCustomStorage="false" AutoStart="true" GCProbability="1"
UseTransparentSessionID="true" TimeOut="3600" />
</code>
where {@link getSessionName SessionName}, {@link getSavePath SavePath},
{@link getCookieMode CookieMode}, {@link getUseCustomStorage
UseCustomStorage}, {@link getAutoStart AutoStart}, {@link getGCProbability
GCProbability}, {@link getUseTransparentSessionID UseTransparentSessionID}
and {@link getTimeOut TimeOut} are configurable properties of THttpSession.

__destruct()   X-Ref
Destructor.
Closes session.


getID()   X-Ref

return: string id of this module

setID($value)   X-Ref

param: string id of this module

init($config)   X-Ref
Initializes the module.
This method is required by IModule.
If AutoStart is true, the session will be started.

param: TXmlElement module configuration

open()   X-Ref
Starts the session if it has not started yet.


close()   X-Ref
Ends the current session and store session data.


destroy()   X-Ref
Destroys all data registered to a session.


getIsStarted()   X-Ref

return: boolean whether the session has started

getSessionID()   X-Ref

return: string the current session ID

setSessionID($value)   X-Ref

param: string the session ID for the current session

getSessionName()   X-Ref

return: string the current session name

setSessionName($value)   X-Ref

param: string the session name for the current session, must be an alphanumeric string, defaults to PHPSESSID

getSavePath()   X-Ref

return: string the current session save path, defaults to '/tmp'.

setSavePath($value)   X-Ref

param: string the current session save path

getUseCustomStorage()   X-Ref

return: boolean whether to use user-specified handlers to store session data. Defaults to false.

setUseCustomStorage($value)   X-Ref

param: boolean whether to use user-specified handlers to store session data.

getCookie()   X-Ref

return: THttpCookie cookie that will be used to store session ID

getCookieMode()   X-Ref

return: THttpSessionCookieMode how to use cookie to store session ID. Defaults to THttpSessionCookieMode::Allow.

setCookieMode($value)   X-Ref

param: THttpSessionCookieMode how to use cookie to store session ID

getAutoStart()   X-Ref

return: boolean whether the session should be automatically started when the session module is initialized, defaults to false.

setAutoStart($value)   X-Ref

param: boolean whether the session should be automatically started when the session module is initialized, defaults to false.

getGCProbability()   X-Ref

return: integer the probability (percentage) that the gc (garbage collection) process is started on every session initialization, defaults to 1 meaning 1% chance.

setGCProbability($value)   X-Ref

param: integer the probability (percentage) that the gc (garbage collection) process is started on every session initialization.

getUseTransparentSessionID()   X-Ref

return: boolean whether transparent sid support is enabled or not, defaults to false.

setUseTransparentSessionID($value)   X-Ref

param: boolean whether transparent sid support is enabled or not.

getTimeout()   X-Ref

return: integer the number of seconds after which data will be seen as 'garbage' and cleaned up, defaults to 1440 seconds.

setTimeout($value)   X-Ref

param: integer the number of seconds after which data will be seen as 'garbage' and cleaned up

_open($savePath,$sessionName)   X-Ref
Session open handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

param: string session save path
param: string session name
return: boolean whether session is opened successfully

_close()   X-Ref
Session close handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

return: boolean whether session is closed successfully

_read($id)   X-Ref
Session read handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

param: string session ID
return: string the session data

_write($id,$data)   X-Ref
Session write handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

param: string session ID
param: string session data
return: boolean whether session write is successful

_destroy($id)   X-Ref
Session destroy handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

param: string session ID
return: boolean whether session is destroyed successfully

_gc($maxLifetime)   X-Ref
Session GC (garbage collection) handler.
This method should be overriden if {@link setUseCustomStorage UseCustomStorage} is set true.

param: integer the number of seconds after which data will be seen as 'garbage' and cleaned up.
return: boolean whether session is GCed successfully

getIterator()   X-Ref
Returns an iterator for traversing the session variables.
This method is required by the interface IteratorAggregate.

return: TSessionIterator an iterator for traversing the session variables.

getCount()   X-Ref

return: integer the number of session variables

count()   X-Ref
Returns the number of items in the session.
This method is required by Countable interface.

return: integer number of items in the session.

getKeys()   X-Ref

return: array the list of session variable names

itemAt($key)   X-Ref
Returns the session variable value with the session variable name.
This method is exactly the same as {@link offsetGet}.

param: mixed the session variable name
return: mixed the session variable value, null if no such variable exists

add($key,$value)   X-Ref
Adds a session variable.
Note, if the specified name already exists, the old value will be removed first.

param: mixed session variable name
param: mixed session variable value

remove($key)   X-Ref
Removes a session variable.

param: mixed the name of the session variable to be removed
return: mixed the removed value, null if no such session variable.

clear()   X-Ref
Removes all session variables


contains($key)   X-Ref

param: mixed session variable name
return: boolean whether there is the named session variable

toArray()   X-Ref

return: array the list of all session variables in array

offsetExists($offset)   X-Ref
This method is required by the interface ArrayAccess.

param: mixed the offset to check on
return: boolean

offsetGet($offset)   X-Ref
This method is required by the interface ArrayAccess.

param: integer the offset to retrieve element.
return: mixed the element at the offset, null if no element is found at the offset

offsetSet($offset,$item)   X-Ref
This method is required by the interface ArrayAccess.

param: integer the offset to set element
param: mixed the element value

offsetUnset($offset)   X-Ref
This method is required by the interface ArrayAccess.

param: mixed the offset to unset element

Classe: TSessionIterator  - X-Ref

TSessionIterator class

TSessionIterator implements Iterator interface.

TSessionIterator is used by THttpSession. It allows THttpSession to return a new iterator
for traversing the session variables.

__construct()   X-Ref
Constructor.

param: array the data to be iterated through

rewind()   X-Ref
Rewinds internal array pointer.
This method is required by the interface Iterator.


key()   X-Ref
Returns the key of the current array element.
This method is required by the interface Iterator.

return: mixed the key of the current array element

current()   X-Ref
Returns the current array element.
This method is required by the interface Iterator.

return: mixed the current array element

next()   X-Ref
Moves the internal pointer to the next array element.
This method is required by the interface Iterator.


valid()   X-Ref
Returns whether there is an element at current position.
This method is required by the interface Iterator.

return: boolean

Classe: THttpSessionCookieMode  - X-Ref

THttpSessionCookieMode class.
THttpSessionCookieMode defines the enumerable type for the possible methods of
using cookies to store session ID.

The following enumerable values are defined:
- None: not using cookie.
- Allow: using cookie.
- Only: using cookie only.



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7