Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining if a session exists 1

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
I am trying to determine if a session exists (or is blank) (to prevent people accessing a page without logging on to a previous page before)

I use this code:

If session("username") OR session("password") = "" then
response.write "You must log-in first."
else
username= session("username")
password= session("password")
end if

and it returns a type mismatch error.

What should the code be?
 
You are missing the = "" on the first statement. Replace your first line with:

If session("username") = "" OR session("password") = "" then
 

inside your global.asa file, have:

sub session_OnStart
session("LoggedIn") = 0
end sub

In the ASP that validates a user's login, put this line after you've checked the username/password is valid:

session("LoggedIn") = 1


At the top any page where the user must be logged in before seeing it just use:

if session(&quot;LoggedIn&quot;) <> 1 then
response.redirect &quot;login.asp&quot;
end if

-Christian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top