Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using Sessions is bad thing, and whats wrong with it?

I know that in community server <sessionState mode="Off" /> which means that you can't use Sessions, and few years ago i remember i was working on a website where we were not allowed to use sessions.
In my point of view sessions are a very helpful tool if we managed how to use the right way, but is using session variable in a website is something bad, when its bad and when its not?

Update
And What can we use instead to avoid its mess?

like image 336
Amr Elgarhy Avatar asked May 07 '10 22:05

Amr Elgarhy


2 Answers

Sessions aren't bad per se. But they should not be abused neither. You must especially avoid the "Oh, I need this piece of information here and here, let's store it in the session and reuse it later".

Instead of doing a proper OO design where information is passed around correctly in parameters, the session is used as a global unorganized storage -- which leads to potential mess.

Such global state also impedes the testability. A big unorganized session also leads to increased memory usage. An alternative to session state can be the viewstate, for instance.

(I don't know if you speak about the session state, or the whole concept of session. If it's the latter, my answer is not really appropriate)

like image 85
ewernli Avatar answered Oct 14 '22 13:10

ewernli


Sessions expire it is volatile so it could happen that sessions time out and such so thats a minus

like image 26
Chino Avatar answered Oct 14 '22 14:10

Chino