Storing session state in cookie v. server

235 views
Skip to first unread message

Kenny Stoltz

unread,
Oct 12, 2012, 10:35:25 AM10/12/12
to ang...@googlegroups.com
I've built out a session service that contains a bunch of generic session information (e.g. stuff like username, current active alerts/modals, the area of the site they're in, etc). Effectively this serves the same use as $rootScope. Currently all this stuff is on a page load and rebuilt by a bunch of REST calls, which seems suboptimal versus just storing the session state somewhere.

I'm curious if people have weighed the pros/cons between serializing this session state out to a cookie versus putting it into a session object and sending it to a server. It would seem that for angular, which is quite client-heavy, storing it in the cookie has some nice properties: no latency, no requirement to accept arbitrary unformatted state info, etc. And design-wise things that are relevant only to the client stay on the client, which has good symmetry.

Has anyone tried it either way and has some advice about the downside/upside of either?

Dan Denno

unread,
Oct 12, 2012, 11:51:50 AM10/12/12
to ang...@googlegroups.com
Using cookies to store application data is not what they were intended to be used for. That is why there is a storage object in HTML 5. Work arounds for this that and I have considered are the jStorage plugin (which feels like a bandaid) and sending that data to the server to store in a Database. Although it might be a good solution for developing around native applications where they sometimes don't have access to the internet. There has been a lot of discussion on how to support older versions of IE when developing an Angular application and these are the options that I have considered. Whether or not to use cookies seems like a common problem that people are running into when the question of data persistance comes up. Personally I prefer to not fight IE7 & 8 and go with the server option. This does add an additional layer of complexity to the application.




--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
 
 

Reply all
Reply to author
Forward
0 new messages