Actions

API15

JSession/set

From Joomla! Documentation

< API15:JSession
Revision as of 12:47, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Set data into the session store

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

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

Returns

mixed Old value of a variable

Defined in

libraries/joomla/session/session.php

Importing

jimport( 'joomla.session.session' );

Source Body

function set($name, $value, $namespace = 'default')
{
        $namespace = '__'.$namespace; //add prefix to namespace to avoid collisions
 
        if($this->_state !== 'active') {
                // @TODO :: generated error here
                return null;
        }
 
        $old = isset($_SESSION[$namespace][$name]) ?  $_SESSION[$namespace][$name] : null;
 
        if (null === $value) {
                unset($_SESSION[$namespace][$name]);
        } else {
                $_SESSION[$namespace][$name] = $value;
        }
 
        return $old;
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />