Yaf_Session::has
Check if a session key exists
Description
public bool Yaf_Session::has(string $name)
Checks whether a session key exists.
Parameters
-
name
-
The session key to check.
Return Values
Returns true if the key exists, false otherwise.
Examples
Example #1 Yaf_Session::has example
<?php
class BaseController extends Yaf_Controller_Abstract
{
public function requireLogin()
{
$session = Yaf_Session::getInstance();
$session->start();
if (!$session->has("user_id")) {
$this->redirect("/account/login");
return false;
}
return true;
}
}
?>
See Also
- Yaf_Session::get
- Yaf_Session::set
- Yaf_Session::del