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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logout a user

Status
Not open for further replies.

brij2002

Programmer
Aug 2, 2002
2
IN
I have made a login script where i check the userid and pwd of a user.
select * from users where userid=userid and pwd=pwd
if rs.eof then
response.write(Invalid login)
else
select * from userloggedin
if rs.eof then
insert into userloggedin where userid=userid and sid=session.sessionid
else
response.write(u are already loggedin )
end if

end if

If a user is logged in and someone tries to login from other place he will get a message 'u are already logged' . I have made a logout page when one clicks on it i delete the userid from userlogged in table. Now if a person closes the browser in between. How do i delete the value from userloggedin table. I tried putting delete code in session_onend but it doesnt work properly. Any other ways to do it ?

brij
 
you should just have to abandon the session and the connection will be lost and they will be logged out automaticaly

in the session_OnEnd
session.abandon You cannot mandate productivity, you must provide the tools to let people become their best.
-Steve Jobs
admin@onpntwebdesigns.com
 
Here is a nifty way to be mean to your users :)
To flag them as logged in, add them to the userlogged table as you are already doing, but also add a date/time. This can be updated on every page with an execute update to the database (saving you a little time an extra db connection will cost on every load). When they try to log on select them from the userlogged table and if the result is not eof then check that the time is < now - 30 minutes. Then you can put up a message saying &quot;Either a user with that name is already logged in, or you improperly logged out of your last session, please wait another x minutes and try again&quot; where x is their last log time + 30 - now.
>:)
If they have an entry in the userlogged table and it is older than 30 minutes, we can safely assume they have left and give them a gentle reminder as we allow them to log back in: &quot;Welcome back, your_name_here, you forgot to log out on your last visit. Logging out is good for your health, promotes good feelings, and doesn't block your access for 30 minutes after you close your browser&quot; :)
or something like that :)
-Tarwn ----------------------
| if(u=getc(this)) |
| putc('\a'); |
----------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top