note 129641 added to function.session-unset
| From: | christian+phpat | Date: | Sun, 07 Jul 2024 16:17:15 +0000 |
| Subject: | note 129641 added to function.session-unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221413@lists.php.net to get a copy of this message | ||
The solution provided by tim at leethost dot com is nice but you must check a active session first,
because else you fill the logs with PHP Errors or Notices depending on your settings. I use it as a
function, and it works smooth.
```php
/** @return void */
public static function sayonara():void
{
if (session_status() !== PHP_SESSION_ACTIVE) :void
{
session_start();
session_unset();
session_destroy();
session_write_close();
setcookie(session_name(), '', 0, '/');
session_regenerate_id(true);
}
}
sayonara();
```
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 217.244.9.139)
----
Manual Page -- https://php.net/manual/en/function.session-unset.php
Edit -- https://main.php.net/note/edit/129641
Del: integrated -- https://main.php.net/note/delete/129641/integrated
Del: useless -- https://main.php.net/note/delete/129641/useless
Del: bad code -- https://main.php.net/note/delete/129641/bad+code
Del: spam -- https://main.php.net/note/delete/129641/spam
Del: non-english -- https://main.php.net/note/delete/129641/non-english
Del: in docs -- https://main.php.net/note/delete/129641/in+docs
Del: other reasons-- https://main.php.net/note/delete/129641
Reject -- https://main.php.net/note/reject/129641
Search -- https://main.php.net/manage/user-notes.php