(Yaf >=1.0.0)
Yaf_Session::offsetGet — Get a session value (ArrayAccess)
Retrieves a session value by key. This method is an alias of Yaf_Session::get() and is called when array syntax is used to read a session object.
nameThe session key to retrieve.
The session value, or null if the key does not exist.
Example #1 Yaf_Session::offsetGet() example
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$session = Yaf_Session::getInstance();
$session->start();
// reading with array syntax calls offsetGet()
$userId = $session["user_id"];
if ($userId === null) {
return $this->redirect("/account/login");
}
echo "logged in as user #", $userId;
}
}
?>