To be honest, it is a little odd that PHP session won’t be destroyed after Apache server got restarted. In order to truly kill the PHP session, especially during development, I created a piece of following code, and ran it everything I wanted to have a clean start:
<?php session_start(); unset($_SESSION['session_name']); session_destroy(); ?>
3 thoughts on “Notes on PHP: Restart apache won’t reset php session”
So, do you think it’s odd? Imagine having a website with a few hundred customers with products in their shopping cart, and for some reason, you need to quickly restart the Apache server because you made a modification in the configuration file. Would you want all of your customer losing their sessions? Would you like it to happen to you? Losing all of your items in your shopping cart after a long time of search, investigation, comparison etc.. ?? It would get you very frustrated I’m sure.
This makes sense! Thanks!
This is because by default PHP saves session to files. Restarting apache will not do anything to clear out these files. See http://php.net/manual/en/session.configuration.php#ini.session.save-handler