PHP 8.6.0 Beta 3 is available for testing

Yaf_Session::getInstance

(Yaf >=1.0.0)

Yaf_Session::getInstanceGet the session singleton

Beschreibung

public static function Yaf_Session::getInstance(): Yaf_Session

Returns the singleton Yaf_Session instance, creating it if necessary. The session is started automatically on first access.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

The Yaf_Session singleton instance, or null if the session could not be started.

Beispiele

Beispiel #1 Yaf_Session::getInstance() example

<?php
$session = Yaf_Session::getInstance();
$session->start();
$session->set("user_id", 42);

// ... later, elsewhere in the application
$same = Yaf_Session::getInstance();

var_dump($same === $session);
var_dump($same->get("user_id"));
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

bool(true)
int(42)

Siehe auch

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top