Cookies in ASP

Posted on 16. Nov, 2007 by tutorials007 in Archive 685 views

What is a cookie

Cookie is a file that is stored in our visitor’s computer.
Cookie can be very useful to store our form values…

How to create a cookie

Response.Cookies(“YourSite”)(“NameCookie”) = “Someone”
Response.Cookies(“YourSite”)(“LastNameCookie”) = “Somebody”
Response.Cookies(“YourSite”).Expires = Now() + 180

This part of code will store your visitor’s name and lastname into cookie named “YourSite”.
Cookie will expire 180 days after it was stored. 
How to retrieve a cookie value

Here you’ll learn how to store a cookie data into the variable.

Dim NameCookie
Dim LastNameCookie

NameCookie = Request.Cookies(“NameCookie”)
LastNameCookie = Request.Cookies(“LastNameCookie”)

Now we’ll print these cookies.

Response.write “Hello. You are ” & NameCookie & ” also called ” & LastNameCookie

And that’s it.

2 Responses to “Cookies in ASP”

  1. Gaurvi jain

    25. Jul, 2009

    Cookies are small bits of information such as strings numeric values stored on the client computer of a specified amount of time.

  2. khairul alam

    06. Nov, 2009

    good,not bad……………..
    but less information……………

Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes