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

Yaf_Session::offsetUnset

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Remove a session key (ArrayAccess)

Description

Yaf_Session::offsetUnset(mixed $name): void

Removes a session key and its value. This method is called when unset() is used with array syntax on a session object.

Parameters

name

The session key to remove.

Return Values

No value is returned.

Examples

Yaf_Session::offsetUnset example

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

$session["captcha_code"] = "8X2Q";

// ... after verifying the captcha, drop the one-time code
unset($session["captcha_code"]);

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

The above example will output something similar to:

output
bool(false)

See Also

  • Yaf_Session::del
  • Yaf_Session::offsetGet
  • Yaf_Session::offsetSet

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