Session Object being Evil - Is it a myth?!!!

Results 1 to 5 of 5

Thread: Session Object being Evil - Is it a myth?!!!

  1. #1
    Chris Small Guest

    Default Session Object being Evil - Is it a myth?!!!

    I have read various articles about the pros and cons of using the Session object to store data over pages, most of them advising not to use them. One of the conns described was that they rely on the client having Cookies enabled.<BR><BR>I have tried switching off Cookies and testing scripts that use the Session object, and they all seemed to be fine to me.<BR><BR>Who is right and are they really all bad (i hope not as i&#039m too lazy to come with alternative methods!)....?

  2. #2
    Join Date
    Dec 1969

    Default RE: Session Object being Evil - Is it a myth?!!!

    Chris,<BR><BR>To be perfectly honest, I don&#039t like &#039em because I don&#039t understand them... I can&#039t see them (as I can a querystring, for example) and the only times I&#039ve tried to use them they have been inconsistent. (I&#039m almost positive that the inconsistency was my fault, but first impressions are the worst.)<BR><BR>The claims against them as far as taking up resources on the server, needing newer browsers to fully support them, etc. are true unless you can prove them otherwise (a la switching off cookies). I feel that session vars are to be avoided as much as possible, especially on high-load sites.<BR><BR>Just my opinion, of course. I&#039m sure plenty of "real sites" use them just fine w/ no problems, but just like Java applets, they are an item to avoid in my book.<BR><BR>Ben

  3. #3
    Join Date
    Dec 1969

    Default RE: Session Object being Evil - Is it a myth?!!!

    I have to disagree with Ben. I&#039ve never had any problem using session variables (though I do avoid assigning recordsets to them). They provide a consistent way to preserve state across pages and I&#039ve never had any issues with the server bogging down because of them. I have, however, seen users mess with query strings and/or try to bookmark a page that needs a query string and then edit the thing and wonder why it doesn&#039t work any more.<BR><BR>For my money, session variables are more reliable and easier to use.

  4. #4
    Join Date
    Dec 1969

    Default Session.evil = True

    In my experience, session vars are very unreliable (not to mention what they do to performance). I always veer away from them. They don&#039t work 100% of the time (ie., if cookies are off like Ben mentioned, OR in the event of multiple servers, aka web-farming they don&#039t maintain state) so I use them VERY VERY sparingly. IMHO - be very afraid.<BR><BR>

  5. #5
    Ian Stallings Guest

    Default no, it's not a myth

    When Microsoft don&#039t use them, take heed.<BR>You can believe what you want, but using the session object<BR>doesn&#039t scale as well as other solutions. Example - <BR>each user to your site starts a session and this loads<BR>a few strings, for this example we&#039ll say they take up <BR>64k of memory(just an example). Now let&#039s say you have around<BR>10,000 users/hour. Quite a bit of traffic but not unheard of<BR>on a large site. Now this wouldn&#039t be so bad if every session<BR>ended when the user stopped sending data. But the server has no <BR>way of knowing that the user has logged off. Their session <BR>variables are still present in memory for 20 minutes.<BR><BR>It doesn&#039t take a huge brain to figure out that during<BR>peak load this will kick the bucket eventually. You can<BR>do two things to alleviate this - <BR>1. horsepower - get more resources (machines, memory, whatever)<BR>2. write the app better<BR><BR>Writing the app without using sessions will increase performance<BR>and free up resources for other processes. If you ever<BR>do any benchmarking with sessions you&#039ll see. When the<BR>resources are gone, they&#039re gone. No more. Notta. The server<BR>will come to a halt. <BR><BR><BR>Im gonna be honest with you though. Sometimes it&#039s better to <BR>throw muscle into it by purchasing more resources. We use sesions<BR>on our site because at this moment it&#039s better to add resources <BR>than rewriting the app (more cost effective). But eventually <BR>there will be limit to how far we can scale. especially with<BR>load balancing, data caching, etc, thrown into the mix.<BR><BR><BR>But regardless, sessions are too be avoided.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts