Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP » General » Downloads
 
Add your own
alternative version
Go to top

Protecting pages with include files

, 14 Sep 2000
An article on how to easily password protect a site using include files
<%response.buffer=true%>
<% 
	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>"
		
		Response.End
	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.

License

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

Share

About the Author

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 15 Sep 2000
Article Copyright 2000 by xicoloko
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid