API16

JSession/get: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Get 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:
Get data from the session store
Get data from the session store


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JSession/get|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JSession/get}}
 
{{subst:Description:JSession/get}}


===Syntax===
===Syntax===
Line 57: Line 55:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JSession/get|Edit See Also]]<nowiki>]</nowiki>
{{subst:SeeAlso:JSession/get}}
</span>
{{SeeAlso:JSession/get}}


===Examples===
===Examples===

Revision as of 14:23, 24 March 2017

Description

Get data from the session store


{{subst:Description:JSession/get}}

Syntax

get($name, $default=null, $namespace= 'default')
Parameter Name Default Value Description
$name Name of a variable
$default null Default value of a variable if not set
$namespace 'default' Namespace to use, default to 'default'

Returns

mixed Value of a variable

Defined in

libraries/joomla/session/session.php

Importing

jimport( 'joomla.session.session' );

Source Body

public function get($name, $default = null, $namespace = 'default')
{
        $namespace = '__'.$namespace; //add prefix to namespace to avoid collisions

        if ($this->_state !== 'active' && $this->_state !== 'expired') {
                // @TODO :: generated error here
                $error = null;
                return $error;
        }

        if (isset($_SESSION[$namespace][$name])) {
                return $_SESSION[$namespace][$name];
        }
        return $default;
}


{{subst:SeeAlso:JSession/get}}

Examples

<CodeExamplesForm />