PHP 8.4.26 Released!

Yaf_Session::offsetSet

(Yaf >=1.0.0)

Yaf_Session::offsetSet — Set a session value (ArrayAccess)

Açıklama

public function Yaf_Session::offsetSet(mixed $name, mixed $value): void

Sets a session value. This method is called when array syntax is used to write to a session object.

Bağımsız Değişkenler

name

The session key to set.

value

The value to store.

Dönen Değerler

No value is returned.

Örnekler

Örnek 1 Yaf_Session::offsetSet() example

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

        // writing with array syntax calls offsetSet()
        $session["user_id"] = $user->getId();
        $session["login_time"] = time();

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

Ayrıca Bakınız

+add a note

User Contributed Notes

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