JavaScript Zone

Script Tutorials

Introduction
Pre-requisites
Installation
Notes

Password Access

Introduction
Related Links


This Javascript demonstrates how to use passwords to restrict access to parts of your web site, for example, adult content.

The users enter a password on the first screen. This password is then verified against a value held in a cookie (for example in a value created by the registration process), and if it matches the restricted second page is loaded, the entered password stored in a temporary cookie.

The second page then re-checks the entered password in the temporary cookie against the stored password cookie. If a match is found, the page is displayed. If the match fails, the user is returned to the first page.

Click on the link below for a demonstration of this script.

Password Demo

Pre-requisites

  • the visitor registration script must already be installed on your web pages
Installation

  1. Cut and paste the following code to your html page as indicated:

Notes

  • this tutorial demonstrates:
    • how to use cookies
  • the code for maintaining cookies is taken from the original date last visited / number of visits javascript from the JavaScript Source - thanks
  • if you use this script, amend the variable names' prefix from pt_ to something meaningful to your site
  • this tutorial can be updated to use encrypted password techniques.


Page last updated 8th August 2001