I have a simple MySQL table - a log of the visitors to my site.
Just before HTML tags I write the visotor's IP, my page id and timestamp to the database. The dfference between two consecutive timestamps gives me the time spent on each page.
That works fine - except for the last page visited.
I don´t know how to record the time spent on the last page of my site. I need the timestamp he leaves. The user may go to another site, close the window or simply switch off his PC.
Any ideas? BODY onunload is unpractical, because Javascript tries to open a new window even if I don¨t write any HTML. And if I open a dummy window with width=0 and height=0 it gives me an ugly blink on the screen.