OK, you have a script that writes a cookie to the browser and now you need to read the cookie each time the user returns to your website. First, we declare a few variables and then we use Request.Cookies to read the cookie from the browser and get our values.
For this example, let’s say that you have a website that allows users to login with a username and password. When a user becomes a member of your site, you write a cookie to their browser that stores their username, password, and any other data you want.
Then, when the user returns to your website, you can read the username, password, and other data from the cookie and use another ASP script to validate their cookie data with your database. As long as the cookie data matches your database data, the user will be able to use your secure web site without any interruption.
Here is how the script looks:
<% DIM strUsername, strPassword, strFirstName, strLastName strUsername = Request.Cookies("MyCookie")("Username") strPassword = Request.Cookies("MyCookie")("Password") strFirstName = Request.Cookies("MyCookie")("strFirstName") strLastName = Request.Cookies("MyCookie")("strLastName") %>
Just replace MyCookie with your own unique cookie name. Now you can read cookies from a browser. If you missed how to write cookies to a browser, be sure to check out Write Cookies to Browser.