JSession/has: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Check wheter data exists in the session store
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki... |
m clean up |
||
| Line 2: | Line 2: | ||
Check wheter data exists in the session store | Check wheter data exists in the session store | ||
{{Description:JSession/has}} | |||
{{subst:Description:JSession/has}} | |||
===Syntax=== | ===Syntax=== | ||
| Line 49: | Line 47: | ||
</source> | </source> | ||
{{subst:SeeAlso:JSession/has}} | |||
{{SeeAlso:JSession/has}} | |||
===Examples=== | ===Examples=== | ||
Revision as of 14:23, 24 March 2017
Description
Check wheter data exists in the session store
{{subst:Description:JSession/has}}
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]);
}
{{subst:SeeAlso:JSession/has}}
Examples
<CodeExamplesForm />