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

saimiris's avatar

Empty session

Hi there,

I am using Laravel 5.1 and I experience a very strange issue.

I am using the Session::set Session::has and Session::forget methods to store / get / empty a session var I need for a multi-step form. The problem is that sometimes (quite often actually) it seems that the Session::forget does not delete the session var. For instance, if on one view I do Session::forget('my_var'); and then check just after the session var content by printing Session::get('my_var'); then it is actually returns 'null' so it seems that the session var is actually deleted. BUT on the next view if I print the Session::get('my_var'); content then it is NOT null anymore!!!!

Is there something I am doing wrong? Does the Session::forget method work only for one single view?

Many thanks.

0 likes
0 replies

Please or to participate in this conversation.