| <%
if (Session("Authenticated")
== 0 || Session("Authenticated")
== null) &&
Request.Cookies("Authenticated")
! = "OK") {
Session("sPage")
= String(Request.ServerVariables("PATH_INFO"));
Response.Redirect("login.asp");
}
%>
Here we are checking to see if the User has been
"Authenticated". If a person has been
"Authenticated" then the Session variable
"Authenticated" will be set to 1 and the Cookie named
"Authenticated" which will be set to "OK" which will
expire in one month.
Here we checking for two different "types" of variables: 1)
Session, & 2) Cookie
We also want to keep track of the page from where the check was
Requested. Once the User is "Authenticated" at the Login
Page he/she will be "directed" back to original page - Session("sPage").
Scope of a Variable
A variable's scope specifies when the application does and does not
have access to the variable. You indicate the scope that you want a
variable to have by declaring the variable in a specific place, such as:
- Application Object - a variable declared here is a
"global variable", which means that it can be seen and
used by anyone who uses the "application". You can use
this scope to pass variables between pages in ASP.
- Session Object - a variable
declared here can be accessed only by the session that creates it
and by any scripts that are run in the user's session. You can use
this scope to pass variables between pages in ASP.
- Script - a variable declared here can be accessed by all
subroutines and functions in the script and by all statements run as
part of the script.
- Procedure - a variable declared here can only be accessed
by the procedure that creates it. Once you declare a variable in a
procedure, you can use it only during that procedure. When the
procedure ends, the script destroys the variable.
|