Martin Martin - 9 months ago 58
AngularJS Question

Expiring cookies with AngularJS?

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


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

Example from documentation:

document.cookie = "someCookieName=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";