Session destroy after redirect other route? my question is when my session is destroy then redirect not in login i want to redirect another route so how to set route and where is set the route in which file or controller please guys help me i dont know how to set
Just update the redirectTo method in App\Http\Middleware\Authenticate
in Middlware/Authenticate
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
replace into ....
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route(' Youre route here ');
}
}
and in route.php
Route::get('/','HomeController@index');
Route::group(['middleware' => ['auth']], function(){
// routes here...
});
You can make another Middlware and just put it...
@sinnbeck sir can you please guide me am i right or wrong
protected function unauthenticated($request, AuthenticationException $exception)
{
return ($request->expectsJson() || $request->isJson())
? response()->json(['message' => $exception->getMessage()], 401)
: redirect()->guest(route('inactivity'))->withErrors([
'failed' => "Please login to access this page"]);
}
i just replace the route in expection/handler file so is thiis correct or not?
Removed that overengineered answer and added a proper one above :)
Please sign in or create an account to participate in this conversation.