asp, read cookie, write cookie, delete cookies, how to read cookies, how to write cookies, how to remove cookies, what is cookie, cookie property, domain property, expires property, path property, secure property, dictionary cookie read, write, delete cookie
(Website Helper) read, write, delete cookie Number of Visitors: Site Map

asp: how to read cookie, write cookie, delete cookies?



Website Design
Website Promotion
Graphic Design
Programming
Free Software
Computer Tips
Discount Stores
This site provides users with the information about asp, read cookie, write cookie, delete cookies, how to read cookies, how to write cookies, how to remove cookies, what is cookie, cookie property, domain property, expires property, path property, secure property, dictionary cookie, and more.

If you think that this site is helpful, please recommend your friends to visit our site.



What is cookie?

Cookie is a small file stored on a user's computer and designed to hold a small amount of data specific relating to a particular client and website. It can be accessed either by the web server or the client computer.

How to read cookie, write cookie, delete cookies in ASP?

The following is the code to read cookie, write cookie, remove cookies in ASP:

1. How to read cookie?


< % Response.buffer = True 'put the data from the form into a variable name = Request.Form("name") 'set the cookie value: Response.Cookies("name") = name % >
2. How to write cookie?


< % 'retrive the data and set it to a variable name = Request.Cookies("name") 'display it on the webpage Response.Write (name) % >
3. How to delete cookies?


< % option explicit response.buffer=true Dim objCookie 'loop through cookie collection Response.Write "Deleting cookies..."< br> For Each objCookie In Request.Cookies 'delete the cookie by setting its expiration Date to a Date In the past Response.Cookies(objCookie).Expires = "September 1, 2000" Next Response.Write "Deletion completed!" % >
Some more information about Cookies:

1. Domain property: It is the domain that the cookie originated from. The cookie can only be read by the domain that it originated from. It is set by default to the domain in which it was created, but you can change it for your needs. The example is as follows:

Response.Cookies("name").Domain = "www.edusoftmax.com"

2. Expires property: It specifies the date the cookie should expire. If it is set to a past date then it will expire when the browser is closed. The example is as follows:

Response.Cookies("name").Expires = Date + 365

or you can also set like the following:

Response.Cookies("name").Expires = #January 01, 2000#

3. Path property: It specifies the exact path on the domain that can use the cookie. The example is as follows:

Response.Cookies("name").Path = "/it/is/the/path"

4. Secure property: If it is set, the cookie will only be set if the browser is using secure sockets or https:// to connect. The example is as follows:

Response.Cookies("name").Secure = True

Please note that it doesn't mean the cookie is secure. It's just like every other cookie, a text file.

5. dictionary cookie: it is just a cookie that can hold several values. For example, user's first and last name stored in one cookie. The example is as follows:

Response.Cookies("name")("first") = "Ray"
Response.Cookies("name")("last") = "Smith"

Please note that there are limits on how much data you can put on a client's browser. Most browsers allow you to put 20 cookies per domain at a maximum of 4k each.

(Website Helper) read, write, delete cookie (c) EduSoftMax - www.edusoftmax.com