I am trying to remove a basic session but it's not removing. Here's the code
welcome.blade.php
@if(Session::has('key'))             
    {{ Session::get('key')}}
    <a href="logout">Sign Out</a>
    @else
        please signin
    @endif
</div>
I don't know how to remove session. Here's the one I used but it's not working route.php
Route::get('/logout', function() {
   $vv =  Session::forget('key');
   if($vv)
   {
        return "signout";
   }
});
                In this article, we will see how to solve Forget Or Remove A Session In Laravel with examples. //remove single session Session::forget('Sessionkey'); //remove multiple sessions Session::forget(['sessionKey1', 'sessionkey2']); //remove all sessions Session::flush();
In order to kill the session altogether, the session ID must also be unset. If a cookie is used to propagate the session ID (default behavior), then the session cookie must be deleted.
The pull method will retrieve and delete an item from the session in a single statement: $value = $request->session()->pull('key', 'default');
You should use this method
 Route::get('/logout', function() {
 Session::forget('key');
  if(!Session::has('key'))
   {
      return "signout";
   }
 });
                        You can try with Session::pull('key');
And if you want to delete all sessions variable you can use Session::flush();
http://laravel.com/docs/5.0/session#session-usage
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