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

muazzamazaz's avatar

Replace session array

I have created laravel session array which is working fine. I need to update array values with new data and for this I am using php function array_replace.

$arr=$request->session::get('key');
$a1=$arr[1];
array_replace($a1,$request);
$request->session::set('key');

But array in session not updated wth data in Request

0 likes
4 replies
Snapey's avatar

You are not setting anything on the session

jlrdw's avatar

When having to redo a session array, many times I find it easier just to tear it down and rebuild the whole thing.

Please or to participate in this conversation.