flash is for one request only, not sure why you are using this?
Nov 7, 2021
4
Level 2
Saving data in a session over several requests
Hello,
I need to create a method that will save data in an array from the first request in a session, and then keep adding data to the array until a certain point.
I got this method but it only saves data from the previous request and isn't adding anything over subsequent requests. Could someone please help out?
public function show(Request $request): View
{
$question = $this->http->getQuestions();
$answers = [
$question['number'],
100,
200,
300
];
if ($request->session()->has('asked_questions')) {
$request->session()->push('asked_questions', $question);
$request->session()->reflash();
}
$request->session()->flash('asked_questions', $question);
return view('question')
->with('question', $question['text'])
->with('answers', $answers);
}
Please or to participate in this conversation.