$cookie question from angular noob

11 views
Skip to first unread message

Derrick Anderson

unread,
Nov 28, 2015, 9:09:37 AM11/28/15
to AngularJS
Hi Everyone,

I'm just coming into Angular from a ColdFusion background, I'm building an Angular app based on 1.4 since I'm reading there is better cookie handling.  My question is kind of general in nature, but I am looking for examples on how to handle persisting a session in a cookie.

What is the best way to set a 1 hour expiration on a session cookie, and have it refresh its expiration date each time the location changes, or programmatically?  Most authentication examples set the cookie for a month or a year in the future which is pretty odd to me.  I suppose one could say there is no 'need' to have it expire after 30 minutes of inactivity if the session is not persisted at the server.  But lets assume mine is persisted at the server, or at least some resource is persisted there that I don't want inactive users hogging up, or it is a security sensitive app.

Is it as simple as checking for the cookie and updating it (if it exists) and updating the time in the 'run' method of my angular app module and also doing that in a $locationChangeStart handler?  How are you pros handling this, any good examples of this out there that I can build from?

Thanks,
Derrick
Reply all
Reply to author
Forward
0 new messages