1

I try to work with Cookie in my website ,but always it marked as session and dont stay for all the time declared , it desespere after the browser close:

Here is my code to create the Cookie :

Cookie::queue('credits_sv', serialize($data), 60 * 24 * 30 * 365);

Here is my code to get data of Cookie :

Cookie::get('credits_sv')

Here the result :

enter image description here

Thank you for any help.

lagbox
  • 48,571
  • 8
  • 72
  • 83
Malek Ben el ouafi
  • 995
  • 12
  • 37

1 Answers1

3

You currently have the cookie lifetime set to 30 years. I think you really meant it to be 1 year instead of 30.

Moreover, from this previous answer:

If you set a date past 2038 in PHP, the number will wrap around and you'll get a cookie that expires instantly.

So to fix the code, change it to:

Cookie::queue('credits_sv', serialize($data), 60 * 24 * 365);

Paras
  • 9,258
  • 31
  • 55