How can I force all users to be logged out in a SPA? I want it so that when I deploy a new version, all users automatically get logged out.
I tried the following, but I'm not sure if it's the safest way to do it.
php artisan key:generate
If your session data is stored in the database, you need to clear the sessions
table. Running a simple SQL query will solve the problem:
DELETE FROM sessions;
If you sessions are stored in files, then as @Karl suggests, you need to delete the session files from the filesystem:
rm -rf storage/framework/sessions/*
The name of the session cookie can also be changed to force all sessions to be invalid, but this is a code change rather than clearing data. The name can be updated in the cookie
key in config/session.php
file. This option is NOT recommended.
You can destroy all the sessions. If you use Laravel Envoy to handle deployments, you can add the following line.
rm -rf storage/framework/sessions/*
If you're using the database session driver, clearing the sessions table is easy.
DB::table('sessions')->truncate();
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