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 preparing for archive only
 
(One intermediate revision by the same user not shown)
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}}
 
 


===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>
 
</span>
{{SeeAlso:JSession/get}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=get
  category=get
  category=JSession
  category=JSession
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:03, 25 March 2017

Description

Get data from the session store



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;
}



Examples

Code Examples