Click here to Skip to main content
11,479,170 members (62,296 online)
Click here to Skip to main content
Articles » Web Development » ASP » General » Downloads
Add your own
alternative version

Protecting pages with include files

, 14 Sep 2000 CPOL 119.4K 1.2K 34
An article on how to easily password protect a site using include files
	Dim strUserID
	Dim strPassword
	Dim bLoginOK

	strUserID   = Request.cookies("userID")
	bLoginOK    = false
	'check if the login is ok
	if (Len(strUserID) > 0) then
		'here you should use a database or a COM component				
		bLoginOK = StrComp(strUserID, "CodeProject") = 0
	end if
	'if the login isn't correct redirect to the login page
	if (not bLoginOK) then
		Dim strFile
		strFile = Mid(Request.ServerVariables("SCRIPT_NAME"), _
				InStrRev(Request.ServerVariables("SCRIPT_NAME"), "/") + 1)
		Response.Write "<form name=formLogin action='login.asp' method=post><input type=hidden name=destiny value='" & strFile & "'></form>"
		Response.Write "<script language=JavaScript>"
		Response.Write "document.formLogin.submit();"
		Response.Write "</script>"
	end if		

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Architect VisionOne AG
Switzerland Switzerland
XicoLoko is a brazilian developer based in Switzerland.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 15 Sep 2000
Article Copyright 2000 by xicoloko
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid