Friday, March 31, 2017

Laravel sessions; Are they cached from when a method is first called?

I have two methods that are called via ajax: The slow one that is called first (sleep is just used to illustrate a method that takes longer to return):

sleep(10);
return Session::get('bucket');

The second one that is called and finishes before the above method:

Session::push('bucket', 'Test');
return Session::get('bucket');

The second one returns the bucket with 'test' in it but when the slow one finishes it returns nothing because it thinks the array is empty even though the second method added something to it.

So is the session cached from when a controller method is first called? It seems like it but I'm not sure.

Cheers!



via BarryWalsh

Advertisement