【发布时间】:2020-05-18 06:30:13
【问题描述】:
我正在尝试使用 laravel 制作用户个人资料!我可以设置会话,我可以在控制器中看到数据,但现在我想压缩配置文件刀片的数据。
public function profile(Request $request)
{
$validatedData = $request->validate([
'email' => 'required|email',
'password' => 'required',
]);
$user = DB::table('user_registers')
->where('email',$request->input('email'))
->first();
if (!empty($user->email)) {
if(Hash::check($request->password, $user->password))
{
$request->session()->put('data',$request->input('email'));
if ($request->session()->has('data')) {
return view('fontend.index')->with('data', $request->input('email'));
}
}else{
return back()->with('password','Incorrect Password!');
}
}else {
return back() ->with('email','Please Insert a valid email');
}
}
【问题讨论】:
-
Why not read the docs? 您还可以使用全局会话 PHP 函数在会话中检索和存储数据。当使用单个字符串参数调用会话助手时,它将返回该会话键的值。 所以只需在您的视图中尝试
session('data')。