Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

User1980's avatar

How to log out all users site wide?

Hello,

How to logout all users site wide in laravel 6 please?

Thank you.

0 likes
7 replies
automica's avatar

@user1980 if you are storing session data in database, then you could just truncate session data and that will invalidate user sessions (and log them out on their next page request).

Snapey's avatar

put the app in maintenance mode?

1 like
thewebartisan7's avatar
Level 14

If you regenerate key in .env then it should did the trick:

php artisan key:generate

This will also logout user with remember me.

Deleting only database table if you are using database sessions or deleting sessions files, will not logout users that login with remember me.

If there are other implications to consider using this approuch depend on your project, since this will break all encryption, so pay attention to this.

3 likes
User1980's avatar

To all,

I first tried to delete the sessions in the storage folder but this was not enough, this only stores the active sessions. What I had to do is also delete all the "remember_token" tokens in the user table.

And then everyone got logged out.

Have to remember this.

User1980's avatar

I would have loved to see a command that does both built inside Laravel.

Snapey's avatar

regenerate the app key, as suggested. This will invalidate all existing user cookies.

1 like
User1980's avatar

Thanks, I always thought the key would also be used to encrypt side wide data, therefore regenerating would cause decryption issues. I did not know it was only for cookies.

Please or to participate in this conversation.