note 121315 added to function.session-destroy
| From: | JBH | Date: | Tue, 04 Jul 2017 15:39:32 +0000 |
| Subject: | note 121315 added to function.session-destroy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209161@lists.php.net to get a copy of this message | ||
I'm using PHP 7.1 and received the following warning when implementing Example #1, above:
PHP message: PHP Warning: session_destroy(): Trying to destroy uninitialized session in...
What I discovered is that clearing $_SESSION and removing the cookie destroys the session, hence the
warning. To avoid the warning while still keeping the value of using session_destroy(), do this
after everything else:
if (session_status() == PHP_SESSION_ACTIVE) { session_destroy(); }
----
Server IP: 72.52.91.14
Probable Submitter: 67.161.220.240
----
Manual Page -- http://php.net/manual/en/function.session-destroy.php
Edit -- https://master.php.net/note/edit/121315
Del: integrated -- https://master.php.net/note/delete/121315/integrated
Del: useless -- https://master.php.net/note/delete/121315/useless
Del: bad code -- https://master.php.net/note/delete/121315/bad+code
Del: spam -- https://master.php.net/note/delete/121315/spam
Del: non-english -- https://master.php.net/note/delete/121315/non-english
Del: in docs -- https://master.php.net/note/delete/121315/in+docs
Del: other reasons-- https://master.php.net/note/delete/121315
Reject -- https://master.php.net/note/reject/121315
Search -- https://master.php.net/manage/user-notes.php