Exiting Laravel 5 or Destruction Session

I am having problems exiting the laravel 5.1 application - I believe that the problem is that the session is not destroyed.

My question is almost identical:

Laravel 5 Auth Logout does not destroy the session

with the caveat that my decision is to use

session_unset();

but not

Session::flush();

so my working solution to exit the laravel 5.1 application:

public function getLogout()
{
    \Auth::logout();
    session_unset();
    return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');

    //these attempts will not remove values from the session.....

    //session()->forget('db');
    //\Session::flush();


}

Any ideas why \Session::flush();and session()->forget('db');do not work?

+5
source share
2 answers

Could you try:

Auth::logout();
Session::flush();

If it does not work, check the sections "'driver' => 'file'"or "'domain' => null"in Config-> Session.php.

+5
source

Try this code

Auth::logout();

or

session_unset();

or

Session::flush();
0
source

Source: https://habr.com/ru/post/1620136/


All Articles