JSession/clear: Difference between revisions
From Joomla! Documentation
New page: ===Description===
Unset data from the session store
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki... |
m clean up |
||
| Line 2: | Line 2: | ||
Unset data from the session store | Unset data from the session store | ||
{{Description:JSession/clear}} | |||
{{subst:Description:JSession/clear}} | |||
===Syntax=== | ===Syntax=== | ||
| Line 55: | Line 53: | ||
</source> | </source> | ||
{{subst:SeeAlso:JSession/clear}} | |||
{{SeeAlso:JSession/clear}} | |||
===Examples=== | ===Examples=== | ||
Revision as of 14:23, 24 March 2017
Description
Unset data from the session store
{{subst:Description:JSession/clear}}
Syntax
clear($name, $namespace= 'default')
| Parameter Name | Default Value | Description |
|---|---|---|
| $name | Name of variable | |
| $namespace | 'default' | Namespace to use, default to 'default' |
Returns
mixed The value from session or NULL if not set
Defined in
libraries/joomla/session/session.php
Importing
jimport( 'joomla.session.session' );
Source Body
public function clear($name, $namespace = 'default')
{
$namespace = '__'.$namespace; //add prefix to namespace to avoid collisions
if ($this->_state !== 'active') {
// @TODO :: generated error here
return null;
}
$value = null;
if (isset($_SESSION[$namespace][$name])) {
$value = $_SESSION[$namespace][$name];
unset($_SESSION[$namespace][$name]);
}
return $value;
}
{{subst:SeeAlso:JSession/clear}}
Examples
<CodeExamplesForm />