PHP 8.5.10 Released!

Yaf_Session::del

(Yaf >=1.0.0)

Yaf_Session::delRemove a session key

Опис

public function Yaf_Session::del(string $name): bool

Removes a session key and its value.

Параметри

name

The session key to remove.

Значення, що повертаються

Returns true on success, or false on failure.

Приклади

Приклад #1 Yaf_Session::del() example

<?php
class VerifyController extends Yaf_Controller_Abstract
{
    public function captchaAction()
    {
        $session = Yaf_Session::getInstance();
        $session->start();

        $expected = $session->get("captcha_code");

        // one-time code: remove it right after use
        $session->del("captcha_code");

        if ($expected === null
            || $this->getRequest()->getPost("code") !== $expected) {
            echo "invalid captcha";
        }
    }
}
?>

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top