JSession

From Joomla! Documentation

Jump to: navigation, search

Description
Provides access to session-state values as well as session-level settings and lifetime management methods.
Provides more advanced features such as expire timeouts.


Member

static mixed &get (string $name, [mixed $default = null], [string $namespace = 'default']) 
mixed set (string $name, mixed $value, [string $namespace = 'default']) 
boolean has (string $name, [string $namespace = 'default']) 
mixed clear (string $name, [string $namespace = 'default']) 
string getToken ([boolean $forceNew = false]) 
static void hasToken (string $tCheck, [boolean $forceExpire = true]) 
integer getExpire () 
JSession &getInstance ( $handler,  $options) 
string getName () 
string getState () 
array getStores () 
boolean restart () 
string _createToken ([int $length = 32]) 
boolean _setCounter () 
boolean _setOptions ( &$options, array $options) 
boolean _setTimers () 
boolean _validate ([boolean $restart = false])

Example

$currentSession = JSession::getInstance('none',array());
$currentSession->set("Name","HaiSon");
$stores = $currentSession->getStores();
 
echo "<br/>Id=" . $currentSession->getId();
echo "<br/>Token=" . $currentSession->getToken();
echo "<br/>Session[Name]=" . $currentSession->get("Name","AA");
echo "<br/>StoreCount=" . sizeof($stores);
foreach($stores as $store) {
  echo "<br/>StoreItem=" . $store;
  echo "<br/>Id=" . $currentSession->getId();
  echo "<br/>Token=" . $currentSession->getToken();
}

See also

Personal tools