26.11.2005, 15:52
Submited in: Asp | Total Views: 29640

What is a cookie

A cookie is a small file that the server stores on the user's computer. Cookies are very useful and you can use them to store password, user last visit, etc.

How to create a cookie

Response.Cookies("YourWebSite")("UserName") = "Marc"
Response.Cookies("YourWebSite")("UserMail") = ""
Response.Cookies("YourWebSite").Expires = Now() + 365

This will store the user's name and e-mail in the cookie "YourWebSite" on the computer.

Cookie will expire after 365 days from the time the cookie was put on the computer.

How to retrieve a cookie value

In this example we will store cookie value in variable.

Dim UserName
Dim UserMail

UserName = Request.Cookies("UserName")
UserMail = Request.Cookies("UserMail")

Response.write "Your name is:" & UserName & " and your mail is: " & UserMail

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category

Most popular tutorials