What is a Cookie?

A cookie can be used to identify a user. It is a small file that the server embeds on the user's computer. Each time the same computer asks for a page through a browser, it will send the cookie too.

With ASP, you can both create cookies and retrieve the value of cookies.

The following output:

Welcome! This is the first time you are visiting this Web page.

Is produced by the following code:

<%
response.cookies("NumVisits").Expires = date + 365
num=request.cookies("NumVisits")

If num = "" Then
   response.cookies("NumVisits") = 1
Else
   response.cookies("NumVisits") = num + 1
End If
%>

<html><body>
<% if num="" then %>
   Welcome! This is the first time you are visiting this Web page.
<% else %>
   You have visited this Web page <% response.write(num) %>  times before
<% end if %>
</body></html>
 

How to Delete Your Cookies

You can delete the cookie set by this page and it will start back over as if you had never visited this page. To delete cookies see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q278835.

On IE5 just follow these steps:

  1. Click TOOLS on the menu
  2. Click INTERNET OPTIONS
  3. Click SETTINGS under Temporary Internet Files
  4. Click VIEW FILES button
  5. Find the file named your computer name. It will have the Internet Address cookie:username@servername/path
  6. Click on the file and hit the DELETE key on your keyboard.