Laravel 5 Auth Logout not destroying session

前端 未结 12 1587
忘掉有多难
忘掉有多难 2021-01-04 00:10

I am using Laravel5 Auth system for my new project, I am able to use registration and login functions with out any problem but logout is not working as expected, however I g

12条回答
  •  再見小時候
    2021-01-04 00:32

    I've been fighting with this, and I've come to a solution.

    In short: The Laravel session reads and writes with middleware. It reads the stored session in at the start of the request, and writes any changes at the end of the request. If you make a redirect, then the current request never finishes, and the middleware write doesn't happen.

    So, how to fix this? Depending on your implementation... you should return the redirect command rather than calling it directly.

    return redirect($redirectAfterLogout)
    

提交回复
热议问题