If you have a web farm, you can't use session variables, since they are bound to a particular web server. Also, session variables take up memory on the server.
Cookies can be used to save information from one session to the next, which session variables can't. However, cookies have limitations too. Each domain is restricted to 20 cookies, and each cookie has a 4k size limit.
A lot depends on the type of application you have, and also the amount of traffic.
Correct me if I am wrong, but don't session objects also use client-side cookies? I think the bigger question is why use Session Objects at all? If you absolutely need to store state information than it should be stored as either a cookie or even better in a Server-side DB. Then you don't have to worry about those browser people that turn cookies off.
The session objet uses cookies to store the Session ID rather than the data on the client machine.
Nick is right - you do need to use cookies when load-balancing, and also if your Server has stability problems then cookies are a better option than the session variable.
As a general rule, cookies are good for saving state across sessions, or when using load balancing. Session variables are good for single session use on a stable machine under acceptable load.
James James Culshaw
jculshaw@active-data-solutions.co.uk
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.