无法在后续请求中检索存储在 Laravel 会话中的数据

Unable to retrieve data stored on Laravel session on subsequent requests

我正在编写一个程序,在将所有经过验证的数据存储到数据库之前,它需要一个多步骤表单。例如,用户必须在进行下一步之前提供他们的个人信息,我希望将经过验证的数据存储为会话,直到用户完成注册,然后所有数据才会存储在数据库中。

到目前为止,这是我的代码:

   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,
       ]]);
   }

会话只能在下一个请求时访问,但不能在后续请求中访问

首先,制作一个数据数组。

 $validates =>[

            '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
    ];

然后最后检查验证并将数据放入具有键和值的会话中。

  if($validated == true){
  $requestUser = collect($validates); 
  Session()->put('requestUser', $requestUser);
}