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

Rainieren's avatar

Laravel - get last session array

Hello, I'm making a step program and therefore I want to use session. I found a way to push all the input values in an array called "basic_settings" like this $request->session()->push('basic_settings', $request->input()); And I found a way to display the first session's specific items in the view like this {{ Session::get('basic_settings')[0]['store_name'] }} But if the user starts again, a new session array will be made called "basic_settings" with the new values, So the other one becomes outdated. How can I display the most recent items from the session in my view? Thanks in advance!

0 likes
1 reply
biishmar's avatar

@Rainieren get the whole basic settings from session and use php native function end to get the last one

$basicSetting = Session::get('basic_settings')[0]['store_name'];

$lastOne = end($basicSettings);

Please or to participate in this conversation.