Artisan command for clearing all session data in Laravel

前端 未结 9 952
北荒
北荒 2021-02-04 02:16

What is the artisan command for clearing all session data in Laravel, I\'m looking for something like:

$ php artisan session:clear

But apparent

9条回答
  •  面向向阳花
    2021-02-04 02:55


    UPDATE: This question seems to be asked quite often and many people are still actively commenting on it.

    In practice, it is a horrible idea to flush sessions using the

    php artisan key:generate
    

    It may wreak all kinds of havoc. The best way to do it is to clear whichever system you are using.


    The Lazy Programmers guide to flushing all sessions:

    php artisan key:generate
    

    Will make all sessions invalid because a new application key is specified

    The not so Lazy approach

    php artisan make:command FlushSessions
    

    and then insert

    truncate();
        }
    }
    

    and then

    php artisan session:flush
    

提交回复
热议问题