Actions

API15

JSessionStorage/getInstance

From Joomla! Documentation

< API15:JSessionStorage
Revision as of 17:11, 22 March 2010 by Doxiki (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

Returns a reference to a session storage handler object, only creating it if it doesn't already exist.

[Edit Descripton]

Description:JSessionStorage/getInstance

Syntax

& getInstance($name= 'none', $options=array())
Parameter Name Default Value Description
$name 'none' $name The session store to instantiate
$options array()

Returns

database A object

Defined in

libraries/joomla/session/storage.php

Importing

jimport( 'joomla.session.storage' );

Source Body

function &getInstance($name = 'none', $options = array())
{
        static $instances;
 
        if (!isset ($instances)) {
                $instances = array ();
        }
 
        $name = strtolower(JFilterInput::clean($name, 'word'));
        if (empty ($instances[$name]))
        {
                $class = 'JSessionStorage'.ucfirst($name);
                if(!class_exists($class))
                {
                        $path = dirname(__FILE__).DS.'storage'.DS.$name.'.php';
                        if (file_exists($path)) {
                                require_once($path);
                        } else {
                                // No call to JError::raiseError here, as it tries to close the non-existing session
                                jexit('Unable to load session storage class: '.$name);
                        }
                }
 
                $instances[$name] = new $class($options);
        }
 
        return $instances[$name];
}

[Edit See Also] SeeAlso:JSessionStorage/getInstance

Examples

<CodeExamplesForm />