note 55380 deleted from function.setcookie by cmb
| From: | cmb@php.net | Date: | Sun, 10 Nov 2019 12:50:18 +0000 |
| Subject: | note 55380 deleted from function.setcookie by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213006@lists.php.net to get a copy of this message | ||
Note Submitter: simon at ruderich dot com
----
If you want to delete a session cookie, you can do it with this code:
<?php
session_start();
// many code
$sessionName = session_name();
$sessionCookie = session_get_cookie_params();
session_destroy();
setcookie($sessionName, false, $sessionCookie['lifetime'],
$sessionCookie['path'], $sessionCookie['domain'],
$sessionCookie['secure']);
?>
This works also well if the session cookie params or the session name were changed.