the complete webmaster
tutorials reviews reference
ASP
CGI
FrontPage
HTML
Java
JavaScript

Sponsored by El Scripto

Visit the Mortgage Loan Place for Home Loans and also click here to find VA Loans on our site.

Get thousands of people selling your product online for FREE

home / articles / frontpage

More FrontPage 98 with ASP and ADO

Last week I wrote an article to introduce you to the possibilities of using the WYSIWYG capabilities of FrontPage 98 to edit ASP pages that connect with a database. I want to take you a bit further today, by discussing the use of the Response and Request Objects' Cookies collections. For my example, I'm using a tutorial I developed at my web site: http://www.connectrans.com/takempis/pword.asp. This tutorial deals with using ASP/ADO to limit access to certain pages by requiring a User Name and Password, which are stored in a database.

Now, people forget their passwords. It's just a fact of life. I wouldn't be surprised if you've forgotten a password or 2 before, eh? I know I have. But if you store a password in a Cookie, they only have to remember it once!

Let's start by looking at the password form as it appears on the page in FrontPage Editor:

cookies3.jpg (23748 bytes)

Notice the default values in the form fields. You can double-click the form field itself to bring up the "form field properties" dialog box. Just type in the ASP code in the box, as illustrated below:

cookie1.jpg (21692 bytes)

This populates the form field with the value of the cookie named "id." In the Request Object, there is a Cookies Collection. To access the value of any given cookie, you just refer to it by name. Of course, you're going to have to set this cookie. This is done in the page following, where the Password and User Name are tested against the database.

The tricky part of this is that the Cookies must be set before any HTML headers are sent to the browser. It's no problem, though, as you can place ASP code anywhere in the page, including above any HTML code. Just go to the "HTML" tab in FrontPage Editor, and place your cursor at the top of the page. I've reproduced the code for the cookies below:

cookie2.jpg (37591 bytes)

Note that I first perform the database operation, then test for "rs.EOF." As I mentioned in last week's article, EOF means "End of File." If this is true when you're at the beginning of the RecordSet, there are no records. In this case, it means that the User Name and Password were not found in the database. You don't want to set the cookies unless you know that the User Name and Password are correct.

You will also note that I've set the Expiration Date for these cookies. If you don't set the Expires property, the cookies will expire at the end of the current session.

Finally, note that the ASP code is above the HTML on the page.

The result of all this is that the first time the user correctly enters his/her User Name and Password, cookies will be set for these 2 values. The next time the user goes to the Password page, the form fields will be filled in already, thereby saving the user from having to remember their User Name and Password, and saving you from having to look them up for them if they forget!

Author: Kevin Spencer
Date: 01/09/98

More articles about Microsoft FrontPage
More articles by Kevin Spencer
Author Biography

Get more website traffic
write for us about us advertise

Copyright 1997, 1998 A Big Lime. All rights reserved.

body>