php8.5
Home/ Manual/ yaf / yaf_session/ Yaf_Session::offsetExists

Yaf_Session::offsetExists

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Check if a session key exists (ArrayAccess)

Description

Yaf_Session::offsetExists(mixed $name): bool

Checks whether a session key exists. This method is an alias of Yaf_Session::has and is called when isset() is used with array syntax.

Parameters

name

The session key to check.

Return Values

Returns true if the key exists, false otherwise.

Examples

Yaf_Session::offsetExists example

php
<?php
$session = Yaf_Session::getInstance();
$session->start();

$session["user_id"] = 42;

var_dump(isset($session["user_id"]));
var_dump(isset($session["user_name"]));
?>

The above example will output something similar to:

output
bool(true)
bool(false)

See Also

  • Yaf_Session::has
  • Yaf_Session::offsetGet

Source: reference/yaf/yaf_session/offsetexists.xml · from the official PHP manual (php/doc-en)