5

I need to be able to store some authentication information in a cookie and set an expiration date.

From what I have seen the $cookie and $cookiestore doesn't support this.

Are there any alternatives or is the only way possible to do this on the server side?

I was hoping maybe there is a module that exposes this functionality?

Thanks in advance

isherwood
  • 58,414
  • 16
  • 114
  • 157
Martin
  • 23,844
  • 55
  • 201
  • 327

2 Answers2

1

jquery-cookie makes this simple. To set a cookie that expires in 30 days,

$.cookie('auth', token, 30);

https://github.com/carhartl/jquery-cookie

skot
  • 428
  • 5
  • 10
0

You could create a cookie from standard JavaScript from within an Angular Ctrl using window.document.cookie.

https://developer.mozilla.org/en-US/docs/Web/API/document.cookie

Example from documentation:

document.cookie = "someCookieName=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";
astone26
  • 1,222
  • 11
  • 16