1

I want to keep my ngCookies after I close the browser. After some research I tried this solution:

var expireDate = new Date();
expireDate.setDate(expireDate.getDate() + 1);
$cookies.put('authenticated', true, {expires: expireDate});

But it sadly only works on F5(refresh). How can I keep the cookies after closing my browser?

1 Answers1

0

Use $cookiesProvider to change the default behavior of the $cookies service.

expires - {string|Date} - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object indicating the exact date/time this cookie will expire.

Reference : https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider#defaults

Community
  • 1
  • 1
Varit J Patel
  • 3,497
  • 1
  • 13
  • 21