Monday, October 21, 2013

Session Object vs Singletons

I have a web application where I would like to pull user settings from a database and store them for Global access. Would it make more sense to store the data in a Singleton, or a Session object? What's the difference between the two?

Session object, definitely.

Singletons exist at the process level. This means that if you have 20 users accessing your site at any given moment, they're using the same singleton object. It's difficult to get used to this concept if you're not doing web development a lot.

Sessions exist at the user level. That means you can store data per user, not per process.

Ref:
http://stackoverflow.com/questions/2821941/session-vs-singleton-pattern

No comments:

Post a Comment

Abstract Factory Vs Factory Method

Abstract Factory Provides an interface for creating families of related or dependent objects without specifying their concrete classes ...