->withInput()
参数后返回到最后一个活动表单。FormController.php:
public function saveForm(){
if(Auth::check()){
//get inputs and submit form
}else{
//redirect to login page
return Redirect::route(login);
}
}
LoginController.php
if(Auth::attempt($loginData)){
//redirect to the last active form before login, with inputs before login
return Redirect::intended('pageName')->withInput();
}
答案 0 :(得分:1)
在Laravel中登录新用户时会创建一个新会话。然后,表单输入之类的旧会话数据将闪烁,因此您无法再访问这些数据。
将输入数据保存在数据库或cookie中会起作用,但对于这种罕见情况,这是很多工作。