JSession/has: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 4: | Line 4: | ||
===Syntax=== | ===Syntax=== | ||
| Line 48: | Line 48: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=has | category=has | ||
category=JSession | category=JSession | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:03, 25 March 2017
Description
Check wheter data exists in the session store
Syntax
has($name, $namespace= 'default')
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | Name of variable | |
| $namespace | 'default' | Namespace to use, default to 'default' |
Returns
boolean True if the variable exists
Defined in
libraries/joomla/session/session.php
Importing
jimport( 'joomla.session.session' );
Source Body
public function has($name, $namespace = 'default')
{
$namespace = '__'.$namespace; //add prefix to namespace to avoid collisions
if ($this->_state !== 'active') {
// @TODO :: generated error here
return null;
}
return isset($_SESSION[$namespace][$name]);
}
Examples
Code Examples