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


In reply to Re: How do i know if an user is not on my site anymore?? by dmitri
in thread How do i know if an user is not on my site anymore?? by pokemonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.