Authenticating user identities in ASP applications (4)

Source: Internet
Author: User
Authenticating user identities in ASP applications (4)

Author: Cactus Studio


Check if the user has been authenticated in the Security page

Each protected page should check whether the user's identity has been validated. This is because the user is likely to
These pages are bookmarked, and if you do not verify that the user is logged in on these pages, you cannot guarantee that the browsing page
is an authorized legal user.

To check whether the user has been authenticated, you can test the session created in Signuseron
("User") is an object, the type is correct, and so on. If the test above fails, redirect the browser to
Login Page signon.asp. For browsers that do not support cookies, check that the user is authenticated
method is slightly more complex, and it needs to obtain the current user record by searching for IDs in application ("Users").
The following code completes the above test in the Signedon page:
<%@ Language=vbscript%>
<% Option Explicit%>
<% Response.Buffer = True%>
<% Response.Expires = 0%>

<!--#INCLUDE file= "Aspsecurity.inc"-->
< html>
< body>
<%
Dim ID
Dim auser
Dim appusers
Dim authenticated
Dim I
If session ("Supportscookies") Then
If not IsUser (session ("User") Then
Response.Redirect "Signon.asp"
Else
Set Auser = Session ("User")
End If
Else
Authenticated = False
id = Request ("id")
If Len (ID) > 0 Then
Appusers = Application ("Users")
For each auser in Appusers
If Auser ("SessionID") = ID Then
Authenticated=true
Auser ("lastactivity") = Now ()
Application.Lock
Application ("Users") = Appusers
Application.UnLock
Exit For
End If
Next
End If
If not authenticated then
Response.Redirect "Signon.asp"
End If
End If
%>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.