Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expiring cookies with AngularJS?

Tags:

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

like image 444
Martin Avatar asked Nov 13 '22 01:11

Martin


1 Answers

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

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

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

like image 157
skot Avatar answered Nov 15 '22 10:11

skot