Sorry guys. This is a coding error.
Session Data Lost Not Sure Why
Hello guys. So there is a part of an application I'm working on where certain pages/urls should not be accessed unless the step that precedes it has been completed. So I created a new middleware class that analyzes the request for these group of specific routes. For some reason though, when I type in a url from one of the completed previous pages/steps, the session data gets lost. Some class where session data is set:
public function subsidyCheck(Request $request)
{
$this->validate($request, [
'subsidy' => 'required'
]);
$subsidyID = $request->input('subsidy');
$request->session()->put('subsidyID', $subsidyID);
....(etc)....
return redirect('enroll/personalinfo');
}
So they advance to the next page. Now let's say I type in the url for the previous step. Here is part of the middleware that is hit:
public function handle($request, Closure $next)
{
...(some logic)...
if (in_array($requestedPage, $pageMap))
{
return $next($request);
}
else
{
return redirect('enroll/zipcode');
}
}
Then this GET Controller and method is hit but the session data is lost:
public function selectSubsidyPage(Request $request)
{
$state = $request->session()->get('lifeline_app.userState');
if (empty($state))
{
// if there is no state the return back to zip code page
return redirect('/enroll/zipcode');
}
```
The state should not be empty or null, but it is and I'm not understanding why.
Please or to participate in this conversation.