PHP 8.6.0 Beta 3 is available for testing

Yaf_Session::get

(Yaf >=1.0.0)

Yaf_Session::getGet a session value

Açıklama

public function Yaf_Session::get(string $name = NULL): mixed

Retrieves a session value by name. If name is omitted or null, the entire session array is returned.

Bağımsız Değişkenler

name

The session key to retrieve, or null to get all session data.

Dönen Değerler

The session value, or null if the key does not exist. When name is null, the full session array is returned.

Örnekler

Örnek 1 Yaf_Session::get() example

<?php
class ProfileController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $session = Yaf_Session::getInstance();
        $session->start();

        $userId = $session->get("user_id");
        if ($userId === null) {
            return $this->redirect("/account/login");
        }

        echo "welcome back, user #", $userId;
    }
}
?>

Ayrıca Bakınız

add a note

User Contributed Notes

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