Trying to build a cute little php site statistics script, now I'm stuck with getting the average visiting time on site. How to do that? I'm using JS badge. HTTP is stateless, if that is the case how the server knows when the visitor navigates away? JS onunload?
You could try recording the first visit, then every subsequent visit, then look at when the last visit was, last visit - first visit = time on site.