php8.5
Home/ Manual/ yaf / yaf_session/ Yaf_Session::__construct

Yaf_Session::__construct

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Constructor of Yaf_Session

Description

Yaf_Session::__construct()

The constructor is private: Yaf_Session implements the singleton pattern and cannot be instantiated directly. Use Yaf_Session::getInstance to obtain the session instance.

Parameters Parameters

Return Values

No value is returned.

Examples

Yaf_Session::__construct example

php
<?php
// The constructor is private, so Yaf_Session cannot be
// instantiated with "new". Access it through the singleton:
$session = Yaf_Session::getInstance();
$session->start();

$session->set("user_id", 42);
echo $session->get("user_id");
?>

See Also

  • Yaf_Session::getInstance
  • Yaf_Session::start

Source: reference/yaf/yaf_session/construct.xml · from the official PHP manual (php/doc-en)