> I don't care about the lastVisit anymore. It does what it's 
> supposed to do. I just want to know if there is a way to do 
> almost the same as lastVisit does, but only updates the 
> parameter when the user has left the webpage.
> Since the function I'm looking for is used in CFForum and 
> other forums, there must be a way. :-)
> 
> Maybe if it could be done with sessions. When the user leave 
> the page and the session is closed, maybe the database can 
> save the current time. And the next time the user visits the 
> page, the time is read from the database to a parameter.
> 
> Though I'm not sure if that's possible to do.

Sessions, client variables, whatever - that part is irrelevant. It doesn't
matter where you store data in this case, simply how you get the data in the
first place.

When a user leaves a page, that user's session continues to exist until the
session timeout has been reached. On the server, there's no guaranteed
reliable way to tell that a user is no longer using the server. All the
server knows is when the last page was requested by the user. That's
inherent to how HTTP works - it's a request-response protocol; when the user
makes a request, the server sends a response and that's the end of the
transaction until the user makes another request.

Using JavaScript, you can capture user-driven events, like when a user
leaves one page to go to another. You can write JavaScript event handlers to
run some code when that happens. You can make all sorts of things happen
this way. For example, you could use the location object to change the URL
of the page (or of a page within a hidden frame or an IFRAME). The page that
you redirect to could then run server-side code to track when it was run,
and that would correspond to when the user triggered the event handler that
you associated with leaving a page. You could use XMLHTTPRequest instead of
using a separate frame, and get the same result.

Again, though, JavaScript solutions cannot be guaranteed to be reliable,
since they happen on the client and not the server.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized 
instruction at our training centers in Washington DC, Atlanta, 
Chicago, Baltimore, Northern Virginia, or on-site at your location. 
Visit http://training.figleaf.com/ for more information!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:204689
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to