ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!



Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
Connections, Commands, And Procedures
What is ASP?
VBScript Classes: Part 1 of N

QUICK TIP:
Query your database with ADO
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Quick Tips


Use the front door, please!
If you require visitors to log in to your site upon each visit, here's a simple way to make sure that they always do so before gaining access to the information on your site. Suppose you require the user to enter their first name into a form on your default.asp page and submit it prior to moving on to main.asp. That's a good start, assuming that your visitors all access your site via the default.asp page. However, unless you take the technique a step further, it would be easy enough to access the content of your site by pointing the browser to a specific page in your site, such as main.asp. You can prevent users from bypassing the default.asp with just a few lines of code.

First, when you process the form data containing the visitor's first name, write the name to a Session variable, as follows:

<% Session("FirstName") = Request.Form("fname") %>


Next, add the following lines of code prior to the <HTML> tag at the top of each page in your site
(except default.asp):
<%
If Session("FirstName") = "" Then
Response.Redirect("default.asp")
End If
%>

If the FirstName Session variable is blank, indicating that the visitor hasn't yet logged in, he'll be redirected to the default.asp page to do so.

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to: webmaster@asp101.com.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers