Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skovmand's avatar

Reflashing Session Data

Hi.

I am redirecting to a registration page with Session flash data using

        return redirect(route('registration.student.token.create'))
            ->with(['authToken' => $token]);

And in the registration controller I want to reflash this data to keep it in the next session also. I do that this way:

    public function create(Request $request)
    {
        $request->session()->reflash();

        return view('registration.student.token.create');
    }

If the user refreshes the page in the browser the session authToken sticks around only for the first refresh, then it disappears.

Am I wrong in thinking it should stick around no matter how much the page is refreshed?

Or am I doing it wrong?

0 likes
2 replies
monsterdream's avatar

I think that you are looking for:

Session::keep(['someData']);

I'm using it when user for example put wrong login information to keep backUrl until login with correct one to redirect back.

skovmand's avatar

I tried it out, the problem is the same. I think the two methods do the same thing, but keep($array) just allows you to keep specific keys only.

1 like

Please or to participate in this conversation.