MAIN MENU
Using cookies with ASP
The Cookies method is very similar to Session method although with cookies the information is saved on the clients computer and not in the server. We need to save and read the information.
To save a cookie use :
<% response.Cookies("cookiename")="cookiedata" %>
To read the cookie
<%=request.Cookies ("cookiename") %>
An example of reading the nuumber of visits someone has made to your site.
<% If Request.Cookies ("NumberVisits")="" Then %>
<% Response.Cookies ("NumberVisits")=1 %>
This is your first visit to this page. Welcome.
<% else %>
<% VarNumberVisits=Request.Cookies ("NumberVisits")
VarNumberVisits=VarNumberVisits+1
Response.Cookies("NumberVisits")=VarNumberVisits %>
Welcome back to this page. You have visited this page <% =VarNumberVisits %> times.
<% End If %>
<% Response.Cookies ("NumberVisits")=1 %>
This is your first visit to this page. Welcome.
<% else %>
<% VarNumberVisits=Request.Cookies ("NumberVisits")
VarNumberVisits=VarNumberVisits+1
Response.Cookies("NumberVisits")=VarNumberVisits %>
Welcome back to this page. You have visited this page <% =VarNumberVisits %> times.
<% End If %>