API15

Difference between revisions of "JSessionStorage/getInstance"

From Joomla! Documentation

< API15:JSessionStorage
(New page: ===Description=== Returns a reference to a session storage handler object, only creating it if it doesn't already exist. <span class="editsection" style="font-size:76%;"> <nowiki>[</n...)
 
m (removing red link to edit, no existant pages)
Line 3: Line 3:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JSessionStorage/getInstance|Edit Descripton]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
  
{{Description:JSessionStorage/getInstance}}
+
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 67: Line 67:
  
 
<span class="editsection" style="font-size:76%;">
 
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JSessionStorage/getInstance|Edit See Also]]<nowiki>]</nowiki>
+
<nowiki>[<! removed edit link to red link >]</nowiki>
 
</span>
 
</span>
{{SeeAlso:JSessionStorage/getInstance}}
+
<! removed transcluded page call, red link never existed >
  
 
===Examples===
 
===Examples===
Line 82: Line 82:
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API15]]

Revision as of 13:47, 12 May 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

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

[<! removed edit link to red link >]

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

Syntax[edit]

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

Returns[edit]

database A object

Defined in[edit]

libraries/joomla/session/storage.php

Importing[edit]

jimport( 'joomla.session.storage' );

Source Body[edit]

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

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

Examples[edit]

<CodeExamplesForm />