Re: ASP Cookies vs. ASP Session variables

by Jeff Nelson <jnelson(at)shadow.net>

 Date:  Thu, 09 Nov 2000 18:48:41 -0500
 To:  "Rasika Wijayaratne" <rasika(at)boursedata.com.au>
 Cc:  hwg-techniques(at)hwg.org
 In-Reply-To:  Rasika2K
  todo: View Thread, Original
At 03:12 PM 11/8/2000 +1100, you wrote:
>I am just wondering what is the main difference in terms of
>implementation/use/performance when it comes to storing values in ASP
>cookies as oppossed to ASP session variables.  I mean since cookies take 
>up much less
>server resources it seesm to make sense to use cookies for all seesion type
>tasks.  The only thing is that the code might be a couple of words longer,
>so its a bit of a hassle to write... annyone have any comments on this?

Rasika,

Whether to implement session variables or cookies is dependant upon the 
following base criteria:
1. Server Resources
2. Web site traffic
The two are inter dependant. Simply stated, if your server resources 
(memory, for the most part) are sufficient, and traffic is ~comparatively~ 
low, the use of session variables should not be detrimental to overall 
performance. Conversely, if the opposite is true (low server resources and 
high traffic) you may wish to consider storing values as cookies. However, 
while technically speaking cookies do indeed consume less resources, in 
actual practice, under most usage scenarios, the use of session variables 
should not result in noticeable performance degradation.

What exactly constitutes "sufficient" server resources? The best (and I 
believe only) answer is "that depends". Hardware configuration, operating 
system, database usage, and CGI all play a significant role. In general, if 
you're satisfied with your servers performance under it's present load, 
you're probably doing OK. Web site traffic is bit easier to define. For all 
practical purposes, I would say that "low" traffic would be around 10,000 
hits per day.

In my own experience, I would generally not hesitate to use session 
variables providing that my server possessed the requisite resources. The 
key, I believe to robust server-side programming is exploiting it's 
strengths while avoiding the inherent weaknesses. Session variables can be 
either.

Hope this helps.

Jeff Nelson

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA