Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php - destroy all sessions [duplicate]

Tags:

php

session

What is the best way to destroy all sessions (not just the one of the current user)?

like image 383
n00b Avatar asked Aug 17 '10 14:08

n00b


1 Answers

It depends on how your sessions are being stored. If they're in a database, just delete them. If they're on the file system somewhere like in /tmp, just delete them. For information on sessions in PHP, check out the manual. http://www.php.net/manual/en/book.session.php

Use session_save_path() to find where your session files are being saved by default, unless you're sending them to a memcached,mysql or such. From terminal or PHP issue the system command. For instance

Shell: rm -rf /var/lib/php/session
PHP: shell_exec('rm -rf '.session_save_path() );
like image 184
Timothy Avatar answered Oct 17 '22 21:10

Timothy