Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

command line to flush php session on linux box

Tags:

linux

php

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?

like image 637
t q Avatar asked Dec 20 '22 15:12

t q


1 Answers

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.

like image 59
Tom Jowitt Avatar answered Dec 29 '22 17:12

Tom Jowitt