PHP 8.6.0 Beta 3 is available for testing

Yaf_Session::set

(Yaf >=1.0.0)

Yaf_Session::setSet a session value

Опис

public function Yaf_Session::set(string $name, mixed $value): bool

Sets a session value.

Параметри

name

The session key to set.

value

The value to store.

Значення, що повертаються

Returns true on success, or false on failure.

Приклади

Приклад #1 Yaf_Session::set() example

<?php
class LoginController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        // ... verify the credentials against the database
        $session = Yaf_Session::getInstance();
        $session->start();

        $session->set("user_id", $user->getId());
        $session->set("login_time", time());

        return $this->redirect("/dashboard");
    }
}
?>

Прогляньте також

add a note

User Contributed Notes

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