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

Sam's avatar
Level 4

Session Forget - Multi Dimensional Array

Hi all,

So I have added some data to my session via

$array = ['vehicle_availability' => ['costs' => $costs]];
Session::push('booking', $array)

If further down the line I wanted to 'remove' the 'vehicle_availablity array from the session how would I go about this?

Using the PHP global $_SESSION I believe the way to have done it would be:

unset($_SESSION['booking']['vehicle_availability']);

Just unsure of the 'laravel way'

0 likes
3 replies
thefuzzy0ne's avatar
Level 6

I think it would be Session::forget('booking.vehicle_availability');

1 like
Sam's avatar
Level 4

Ah dot notation...

Seems to work - is this documented anywhere?

thefuzzy0ne's avatar

Not exactly. I just took a stab at it based on the docs for Session::push(), which uses dot notation. :)

2 likes

Please or to participate in this conversation.