On logout from my Laravel application using the Laravel logout method:
public function getLogout()
{
Auth::logout();
return Redirect::to('users/login')->with('message', '<div class="alert alert-success">Your have successfully logged out</div>');
}
I am successfully logged out, but on hitting the back button, I can still access my account. Any idea on how I can fix this?
I am new to laravel, so I'm not sure if my question makes sense. Well in plain PHP, manually resetting the session to null has always done the job for me.
Here is how I solved it in Laravel 5 usign middleware:
Create a NoCache middleware like this:
Go through this: How do I implement before vs. after filters in middleware?
class NoCache {
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
return $response;
}
}
Then register this middleware in kernel.php: Running middleware on every request
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