Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Session::delYaf_Session::getInstance>
^Yaf_SessionLast updated: Mon, 26 Oct 2026

Yaf_Session::get

(Yaf >=1.0.0)

Yaf_Session::get — Get a session value

Description

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.

Parameters

name

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

Return Values

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

Examples

Example #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;
    }
}
?>

See Also


<Yaf_Session::delYaf_Session::getInstance>
^Yaf_SessionLast updated: Mon, 26 Oct 2026