"Anthony Jones" <An*@yadayadayada.comwrote in message
news:uA*************@TK2MSFTNGP02.phx.gbl...
>
"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@194.109.133.242...
>go****@walkerwebworks.co.uk wrote on 01 feb 2007 in
microsoft.public.inetserver.asp.general:
here is my code
logon is set to 1 in a include that is only on member pages
<%if logon<>1 then
if session("user_ID") <0 OR Session("user_ID") <"" then
This boolean is always true!!!!
The boolean can only be false,
if session("user_ID") is both 0 and "" at the same time,
which is impossible.
Are you sure? What if Session("User_ID") is empty?
This code would be better:-
If Session("User_ID") = Empty Then
-A starter template-
' loggedin.asp - included in members only pages
<%
dim username
username = session("username")
if username = "" then Response.Redirect "login.asp"
%>
' common.asp
<%
sub prt(str)
Response.Write str & vbCrLf
end sub
sub lprt(str)
Response.Write str & "<br />" & vbCrLf
end sub
%>
' login.asp
<%@ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
%>
<!--#include file="common.asp"-->
<%
dim method
method = Request.ServerVariables(""Request_Method")
if method = "POST" then
' process login
' ...
' if login successful
session("username") = rs("username")
Response.Redirect "welcome.asp"
else
prt "<html>
prt "<head>"
prt "<title>Login</title>"
prt "</head>"
prt "<body>"
prt "<form action="""" method=""post"">"
lprt "Username: <input type=""text"" name=""username"" value="""" />"
lprt "Password: <input type=""password"" name=""password"" value="""" />"
lprt "<input type=""submit"" value=""Login"" />"
prt "</form>
lprt "Not a member? <input type=""button"" value=""Register""
onclick=""locaton.href='register.asp'"" />"
lprt "You can also browse our site as a visitor by clicking <a
href=""visitor.asp"">here</a>."
lprt "You must register to have full access to the site."
prt "</body>"
prt "</html>"
%>
' welcome.asp
<@ Language="VBScript" %>
<%
Option Explicit
Response.Buffer = True
%>
<!--#include file="loggedin.asp"-->
<!--#include file="common.asp"-->
<%
' code goes here
prt "<div class=""toolbar"">Username: " & username & " <a
href=""location.href='logout.asp'"">logout</a></div>"
' ...
%>
' logout.asp
<%
session.Abandon
Response.Redirect "login.asp"
%>