I have a LAMP stack on AWS centOS linux. After updating my site i would like to force all users to re login by clearing all sessions.
What is the best way to do this?
Is there a way to flush out all sessions currently in PHP?
This very much depends on where your application stores the session. If you have not manually overridden the session handler in your project it will default to whatever the path is in your php.ini file. To locate your php.ini file:
$ find / -name php.ini
On CentOS it's usually found in /etc/php.ini.
Check php.ini for the session save path (defaults to /tmp I think on PHP-FPM CentOS installs):
session.save_path = "/var/lib/php/session"
Delete the contents of the specified folder:
$ rm -Rf /var/lib/php/session/*
Now all of the current user sessions should be cleared. If you store sessions in the DB or memory, you will need to clear the sessions manually via whatever software you use for session management.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With