Program Code – Create Cookies

The code was written in VBScript. The code is created as a cookie that calculated the number of times a user visits a particular page. This code was run into an ASP server.

The syntax for if … then else :

If condition Then [statements]
 Else [elsestatements]
<%
dim numvisits
response.cookies("NumVisits").Expires=date+365
numvisits=request.cookies("NumVisits")
      if numvisits="" then
         response.cookies("NumVisits")=1
         response.write("Welcome! This is the first time you are visiting this web page.")
      else
        response.cookies("NumVisits")=numvisits+1
        response.write("You have visited this")
        response.write("Web page"&numvisits)
         if numvisits=1 then
          response.write "time before!"
         else
           response.write"times before!"
         end if
        end if
%>
<html>
<body>
</body>
</html>

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.