Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How do i know if an user is not on my site anymore??

by dmitri (Priest)
on Mar 08, 2001 at 20:12 UTC ( #62981=note: print w/replies, xml ) Need Help??


in reply to How do i know if an user is not on my site anymore??

Here are a couple of quite painless ways to do this.

Solution No. 1
Create a CGI script that works with a database and returns (prints) an image. Then, in your web pages, you can set up JavaScript code to reload an image (which can be very small) every 15 seconds or so. Now, the image source will be that CGI program. Every time the CGI is invoked, it will log username and time to the database. Now, to find out who is logged in,

SELECT USERNAME FROM LOGGED_IN WHERE LAST_TIME > NOW() - 15

The SQL will be db-specific, but you get the point. The good thing about this approach is that you don't need a separate frame. The downside is that you have to know some JavaScript.

Solution No. 2
This one includes a Java Applet. On initialization, it can send HTTP request and log the user in. When the user leaves your site or closes his browser, the cleanup procedure is invoked, which can log the user out (delete a record from a database or a file).

The second way is not very good if someone trips over his powercord, or Netscape crashes. You pick the way to do it.

$.02

  • Comment on Re: How do i know if an user is not on my site anymore??

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://62981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-12-06 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?