Sunday, March 5, 2017

How to remove an item from session array in laravel

Here is the problem I have a session

session('products')

this is actually an array that contains id

session('products')
1
2
3
4
5

Now I want to delete lets say 4 How do I do that? I tried method

session()->pull($product, 'products');

But it didn't work!

Other solution

session()->forget('products', $product);

it also didn't work



via Alen

Advertisement