Facebook Twitter Reddit LinkedIn

Using Cookies in your ASP page

Cookies, those small files that live in the Temporary Internet Files folder, are a great way to personalize your Active Server web pages. The following ASP/HTML code creates a page that will ask a user to enter their name the first time they visit the page, then recognize and greet them by name each subsequent visit.

At the top of your page:

IF NOT (Request.Form("Name") = "") THEN
Response.Cookies("Name") = Request.Form("Name")
Response.Cookies("Name").Expires = "Jan 1, 2000"

In the Body of your page:

IF Request.Cookies("Name") = "" THEN
Response.Write("<FORM Method=Post>Enter Your Name: ")
Response.Write("<INPUT Type=Text Name=Name> ")
Response.Write("<INPUT Type=Submit></FORM>")
Response.Write("Welcome back, "&Request.Cookies("Name"))

Source: Anonymous
© 2007-2019 All rights reserved.   Part of the somuch.com group of trusted web sites.   PO Box 351031, Palm Coast FL 32135-1031