Home | Advertising Info181 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Saturday, September 23, 2017  


Simple Password Protection With a Cookie




If you just need to password protect a single page or a series of pages and you don't need multiple users this simple code can be pasted at the top of the page or pages. In this version of the code we use a cookie to keep track of the password access so the user does not have to log in again when they come back to the page or pages. This is also a good example of how to use cookies.

You can change the password in the code. It is set to "sample" right now.

All you need to do is make sure the form posts to itself.
For example: If the page you paste this code into is called "guestbook.asp"
You would change the action of the form to "guestbook.asp".

If you like this concept check out this awesome application...
It works in a similar same way, but has a user database as well as many advanced features.

http://www.ASPProtect.com
 

Paste the code below directly under the
<%@ LANGUAGE="VBSCRIPT" %> on your asp page. Then underneath all of this code have the entire contents of your page as normal including your own set of body and html tags. If the correct password is entered you will see your page instead of the input form and it will remember that you are logged in with a cookie. That's all there is to it... pretty easy ehh.


<%
Response.Buffer = True
STATUS = Request("STATUS")
PASSWORD = Request("PASSWORD")
 
If STATUS = "CHECKEM" Then
     If PASSWORD = "sample" THEN
        Response.Cookies ("PASSWORDACCESS")("Access") = "Yes"
        Response.Cookies ("PASSWORDACCESS").Expires = DATE + 256
     End If
End If
 
If Request.Cookies("PASSWORDACCESS")("Access") <> "Yes" Then
%>

<HTML>
<BODY>
<form method="POST" action="thispage.asp">
<center>
<input type="PASSWORD" name="PASSWORD" size="10"><br>
<input type="hidden" value="CHECKEM" Name="STATUS" >
<input type="submit" value="Login">
</center>
</form>
</BODY>
</HTML>
<%
Response.End
End If
%>


 

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright 1998 - 2017 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP ASP.NET .aspx .ascx Web HTML Developer Internet Microsoft Web Services Visual Studio .NET CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com