laravel 重定向是否会删除session
注册时,在postRegister方法里打印
代码如下:
路由:
中间件:
$this->auth->guest(),打印结果是false,然后 我重定向至根目录,在通过auth 中间件时,显示的打印结果就是true了,请问这是什么问题呢?
代码如下:
/**
* 注册提交
* @param SignUpRequest $request
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function postRegister(Request $request)
{
$all = $request->except(['_token','password_confirmation','read']);
$result = CarDealer::register($all);
dd($this->auth->guest());
return redirect('/');
}
路由:
Route::group(['middleware'=>'auth'],function(){
Route::get('/', 'IndexController@index');
});
Route::controllers([
'auth' =>'Auth\AuthController'
]);
中间件:
public function handle($request, Closure $next)
{
dd($this->auth->guest());
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('auth/login');
}
}
return $next($request);
}
2 个回复
qishawoye0
赞同来自:
raywill
赞同来自: