Last Updated: January 28, 2019
·
11.42K
· wern

Laravel logout

Route::filter('nocache', function($route, $request, $response)
{
  $response->header('Expires', 'Tue, 1 Jan 1980 00:00:00 GMT');
  $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0,    pre-check=0');
  $response->header('Pragma', 'no-cache');
  return $response;
});

Route::group(array('before' => 'auth', 'after' => 'nocache'), function()
{
   Route::get('/admin', function(){
   return 'Im an admin page';
 });

Route::get('/admin/logout', function(){
    Session::flush();
    Auth::logout();
    return Redirect::to("/login")
      ->with('message', array('type' => 'success', 'text' => 'You have successfully logged out'));
});

});