Level 51
You’re just getting you have to put to save it into the session again.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i am trying to update a specific value in the session that has array collection but it doesn't seem to work
here is the array
Illuminate\Support\Collection {#596 ▼
#items: array:6 [▼
0 => array:4 [▼
"id" => "jj"
"name" => "k"
"date" => "ghj"
"test" => array:1 [▶]
]
1 => array:3 [▶]
2 => array:3 [▶]
3 => array:3 [▶]
4 => array:3 [▶]
5 => array:3 [▶]
]
#escapeWhenCastingToString: false
}
and this is my code
foreach (session()->get('key')as $keys => $values) {
if (session()->get('key')[$keys]["id"] == 'jj') {
session()->get('key')->map(function ($object, $keys) {
// Add the new property
$object[$keys]["id"] = 'works';
// Return the new object
return $object;
});
}
}
@webrobert i found another way where i unset the array key and update with the new data
Please or to participate in this conversation.