basic global.asa thingy

L

Lasse Edsvik

Hello

I have login-page where i set the column LoggedIn = 'Y' when a user logs
in, i was wondering if you guys could help me set up my global.asa so
correctly so it sets LoggedIn='N' when Session("UserID") times out.

what is needed besides:


set conn=server.createobject("adodb.connection")
conn.open connstr
sql="update users set loggedin='N' where userid="&session("userid")
conn.execute(sql)
set conn=nothing

?

do i need to set something up in the IIS too or?

TIA
/Lasse
 
D

Dan Brussee

Hello

I have login-page where i set the column LoggedIn = 'Y' when a user logs
in, i was wondering if you guys could help me set up my global.asa so
correctly so it sets LoggedIn='N' when Session("UserID") times out.

what is needed besides:


set conn=server.createobject("adodb.connection")
conn.open connstr
sql="update users set loggedin='N' where userid="&session("userid")
conn.execute(sql)
set conn=nothing

This is not going to work for you. Two of many reasons are:

1. By your specification, the SQL statement defined will run when the
session times out. Therefore, the "userid" value in the session
collection will not exist, so you dont know who to log out.

2. The code you specify runs on the server. If a user simply leaves
their browser open without activity, or closes it, the server gets no
trigger to run the code. Session timeout does not occur as a trigger
on the server.
 
R

Randy Rahbar

Instead of using this method, what about setting a session variable (say
session("LoggedIn")) when the user logs in, then you can check for this in
your code to ensure the user is still logged in....

if isLoggedIn then
'yep, the user is still logged in
end if

function isLoggedIn
if len(session("LoggedIn")) > 0 then
isLoggedIn = True
else
isLoggedIn = False
end if
end function

If you have a manual logout, then you can set session("LoggedIn") = "" when
the user logs out.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top