无法在后续请求中检索 Laravel 会话中存储的数据
我正在编写一个程序,在将所有经过验证的数据存储在数据库中之前,需要多步骤表单。例如,用户必须在继续下一步之前提供他们的个人信息,我希望将验证的数据存储为会话,直到用户完成注册,然后所有数据才会存储在数据库中。
到目前为止,这是我的代码:
if($validated == true){
session(['reg_user' =>[
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'dob' => $request->dob,
'email' => $request->email,
'phone' => $request->phone,
'title' => $request->title,
'country' => $request->country,
'state' => $request->state,
'city' => $request->city,
'zipcode' => $request->zipcode,
'address' => $request->address,
]]);
}
该会话只能在下一个请求时访问,但不能在后续请求中访问
I am writing a programme that requires a multi-step form before all the validated data will be stored in the database. For instance, Users have to provide their personal information before proceeding to the next step, and I want the validated data to be stored as a session up till the user completed its registration before all the data will be stored in a database.
Here is my code so far:
if($validated == true){
session(['reg_user' =>[
'firstname' => $request->firstname,
'lastname' => $request->lastname,
'dob' => $request->dob,
'email' => $request->email,
'phone' => $request->phone,
'title' => $request->title,
'country' => $request->country,
'state' => $request->state,
'city' => $request->city,
'zipcode' => $request->zipcode,
'address' => $request->address,
]]);
}
The session is only accessible on the next request but not on subsequent requests
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,制作一个数据数组。
然后最后检查验证并将数据放入带有键和值的会话中。
First, make an array of data.
Then finally check the validation and put the data into a session with key and value.