login

B

bender

Im in the process of making a login script. I was thinking of doing
something like
session("User") = rs("Username")

but how do I check if a user is already logged in or not ? I mean, if the
user isnt' logged in then the session variable isnt created and I would get
an variable error of some kind. Just looking for some input.

Cheers :)
 
K

Khanh Pham

check the form text field name and compare it to the session. if it matches
then the user already logged in. use something like:

if request.form("userid") = Session("userid") then
'already logged in
else
'continue processing checking against database
end if

hope this helps
 
D

Dan Brussee

Im in the process of making a login script. I was thinking of doing
something like
session("User") = rs("Username")

but how do I check if a user is already logged in or not ? I mean, if the
user isnt' logged in then the session variable isnt created and I would get
an variable error of some kind. Just looking for some input.

The session "OBJECT" is always there. It is a collection of items...
one of which may be named "User". If that item does not exist when you
test it's value, then a blank string will be returned...

if session("User") = "" then ' Nobody has logged in yet
 
P

PB4FUN

I mostly use an include file that does a check like this :

If Session("User") = "" then
response.redirect "login.asp"

else
'Do nothing
end if

In the login.asp you do a Select count(username) From ...... query
where you check for the Request("Username") and the Request("password")

After getting the RS do this :

If Rs.fields(0).Value > 0 then
Session("User") = strLoginName 'from the Request("Username")
else
Response.write "User not found or wrong password."
end if

Meindert, MCP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top