Get out of corrupted session
| From: | Côme Chilliet | Date: | Wed, 26 Apr 2017 14:13:57 +0000 |
| Subject: | Get out of corrupted session | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-326069@lists.php.net to get a copy of this message | ||
Hello,
When there is corrupted or invalid data in the session, it triggers a Fatal error when calling
session_start.
My problem is the data is still in the session so there is no way to get out of this fatal error
other than deleting the cookie by hand.
I would like to destroy the session in case of fatal error, which seems a pretty reasonnable
behavior.
Is there any way to do this ? I heard of register_shutdown_function but it seems to be called even
when no errors occurs. Can the method called detect if it was called by a fatal error or not ?
I’d like a solution which works with PHP5 as well (I know that more errors are catchable in PHP7).
Côme