Home

Cookies are used to store value of a variable on the users pc. For example a login name and password can be stored on the users pc and when the user visits the site again, he does not need to put his login information again.

Cookies.

Here we will save one cookie first and the retrieve the value. The expiry date needs to be set or the cookie will die when browser is closed.

In the second example we are checking if a cookie exists and decide what to say to that web browser. For example , if we stored the user login name and password earlier, then we could get him logged in to a secured area bypassing the login page.

<%
'Save a cookie
Response.Cookies ("myCookie") = "Hello"
Response.Cookies("myCookie").Expires=#May 10,2023#


'Get cookie value
response.write
Request.Cookies ("myCookie")
%>

<hr>

<%

'Chek if a cookie exist and decide what to say.

if
Request.Cookies ("myCookie") ="Hello" Then
  response.write "Welcome Again. <br>"
else
  response.write "Welcome for the first time. <br>"
End if

%>
 

[Download Sample Code]