Writing Cookies in asp.net
The browser manages cookies on a user system. Cookies are sent to the browser via the HttpResponse object that exposes a collection called Cookies. You can access the HttpResponse object as the Response property of your Page class. Any cookies that you want to send to the browser must be added to this collection. When creating a cookie, you specify a Name and Value. Each cookie must have a unique name so that it can be identified later when reading it from the browser. Because cookies are stored by name, naming two cookies the same will cause one to be overwritten.
You can also set a cookie's date and time expiration. Expired cookies are deleted by the browser when a user visits the site that wrote the cookies. The expiration of a cookie should be set for as long as your application considers the cookie value to be valid. For a cookie to effectively never expire, you can set the expiration date to be 50 years from now.
Note: Users can clear the cookies on their computer at any time. Utilities such as CCleaner ("crap cleaner") allow you to set the cookies you want to keep, and delete all the rest.
If you do not set the cookie's expiration, the cookie is created but it is not stored on the user's hard disk. Instead, the cookie is maintained in memory as part of the user's session information. When the user closes the browser, the cookie is discarded. A non-persistent cookie like this is useful for information that needs to be stored for only a short time or that for security reasons should not be written to disk on the client computer. For example, non-persistent cookies are useful if the user is working on a public computer, where you do not want to write the cookie to disk.
Recent Posts
- Error message when you try to install SQL Server 2008 if the path of the SQL Server 2008 installation media contains a number sign (#) character: “Could not load file or assembly ‘<Path>\Mi …
- Employee Performance Appraisal System: An Overview
- CMYK versus RGB color spectrum
- Description of the Jet 4.0 Database Engine hotfix package for Windows XP SP2, Windows Server 2003 SP1, Windows Server 2003 SP2, Windows Vista, Windows Vista SP1, and Windows Server 2008: October …
- Adobe training in Sydney from Creative Mentor
- Business Card Do's and Don'ts
- Unique Gifts – Chalk Mugs
- Turn One Of The Bahamas Houses For Sale As A Holiday Home
- Tips To Hire A Professional Web Design Company
- The 10 Factors That Affect and Predict Stock Prices
Tag Cloud
-
application
ASP
assembly
career
class
code
company
constructor
control
Database
difference
Don
employer
error
Exception
hiring manager
information
interview
interviewer
job
job seekers
manager
method
NET
page
person
position
Process
property
question
quot
response
Serialization
Server
session state
site
SQL
State
system
time
type
void
way
web
work
BlogRoll
Archives
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
- January 2011
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009