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
  • 52,576
  • 15
  • 105
  • 143
Martin
  • 23,074
  • 53
  • 198
  • 315

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
  • 252
  • 3
  • 7
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,192
  • 10
  • 16