mrincon
Posts: 14
|
Posted: 02/26/2004, 2:29 PM |
|
Hi friends, I'm using a field on a table which saves the users information to save when a user is logged. When a user login in the app, there is a mysql query ("UPDATE users SET logged='Y' WHERE iduser=" . $db->ToSQL(CCGetSession("UserID"),ccsInteger); and all is fine until the user logs out in a formal manner (clicking a special link), but when the user still with the browser open but not working, he is disconnected by time, and I don't know how, when or where execute the opposite operation to set the field "logged" to 'N'. Then the user always appear as connected if he/she still not working or close the browser without click on the Logout link, wich is on the header page. Anyone knows how to do that? Thanks in advance.
_________________
Manuel Rincon
Colombia |
|
|
peterr
Posts: 5971
|
Posted: 02/26/2004, 2:44 PM |
|
If someone was disconnected or closed their browser then nothing is sent to your server and your server doesn't run any programs that could update user's status.
See: http://forums.codecharge.com/posts.php?post_id=42883 http://forums.codecharge.com/posts.php?post_id=42774
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
DonB
|
Posted: 02/26/2004, 3:45 PM |
|
Your best bet (OK, just my opinion) is not to log a boolean that they've
connected, but to record the time when they connected. At some key point in
the app (like if there is a main page they go to regularly) update that time
value each time they pass through. This way, if you query for users whose
timestamp is not older than some reasonable interval of time (maybe 10
minutes), then you get an approximation of how many users are connected.
This is what is implemented in most forum software packages that show you
how many users are connected. It's not EXACTLY how many are connected right
now, but how many got connected within the past few minutes. That's about
the best you can hope for.
Some webservers might let you enumerate the active sessions and report that,
but generally I don't think that something you will be able do (for security
reasons).
Some databases will allow you to query for the active database connections.
Maybe that would be a more accurate way to go about it.
--
DonB
http://www.gotodon.com/ccbth
"mrincon" <mrincon@forum.codecharge> wrote in message
news:5403e73383c300@news.codecharge.com...
> Hi friends, I'm using a field on a table which saves the users
information to save when a user is logged. When a user login in the app,
there is a mysql query ("UPDATE users SET logged='Y' WHERE iduser=" .
$db->ToSQL(CCGetSession("UserID"),ccsInteger); and all is fine until the
user logs out in a formal manner (clicking a special link), but when the
user still with the browser open but not working, he is disconnected by
time, and I don't know how, when or where execute the opposite operation to
set the field "logged" to 'N'. Then the user always appear as connected if
he/she still not working or close the browser without click on the Logout
link, wich is on the header page. Anyone knows how to do that? Thanks in
advance.
>
> _________________
> Manuel Rincon
> Colombia
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
Michael Mikkelsen
|
Posted: 02/26/2004, 8:50 PM |
|
One thing that I want to recommend is redirecting the user back to the login page after a certain amount of time.
<META HTTP-EQUIV="Refresh" CONTENT="600; URL=http://www.newlocation.com/login.php">
Then you can have that page log them out (i.e. CCLogoutUser() ) and update the database. This eliminates the problem of them thinking that they are logged in when actually their session has expired.
Of course this doesn't solve the problem of updating the database if they close their browser but it does solve other potential problems and it is a good step in the right direction for this problem.
BTW, if you use a date instead of a bool, you never really need to update the database when they log out.
Michael Mikkelsen
mike@kccoupon.com
|
|
|
|