Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decision to add objects to different httpcontext

Status
Not open for further replies.

vcllvc

Programmer
Jul 12, 2001
136
US
can someone give me some guideline about when to add objects to either session, HTTPContext.Items, or Cookies?

What is the best practice on that?

Thanks in advance !

Vincent
 
HttpContext.Items - Only lasts until the request has ended and the page is sent to the user. Use it wherever you have a bit of data that you want to cache, but get rid of when the page is done processing.

Session - Secure info that never leaves the server and exists for the length of a user's session. Use it for large amounts of data that you must store or things you don't want the user to have access to. Be warned that if you have a larger application, storing a lot of items in session can eat up the server's memory.

Cookies - Can be per session or until you set the cookie to expire or the user/browser deletes them. There's a 4k size limit and you're limited to so many cookies per domain so keep the amount of information small and be aware that the cookies are sent from the browser with every request whether you use them or not. Use it for small amounts of data that will either keep the server memory from being taxed or be persisted long-term.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top