Knowing when a user leaves my site - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Knowing when a user leaves my site

Dave1Dave1 Posts: 5Member
Could someone please tell me if there is a way to determine when a user
has left my site.

Cheers!!

Dave!!

Comments

  • ggxggx Posts: 4Member
    Well, I know two ways to do this:
    1) You can use the onUnload event in JavaScript (which is not perl-related) to perform commands (like calling a perl script for example (you can do this with parent.location='blah.pl', read more about it in the JavaScript primer at www.htmlgoodies.com)). I'm not sure if you can check if the new page the person is visiting is on your site or not.
    2) or, you can use cookies. You can use a cookie that 'unsets' itself after 2 minutes for example. Then, you can check if the cookie is set or not. If it's set, then it means that user is active, and if not, then it means he/she did not do an action in the previous 2 minutes. NOTE that you must reset the cookie whenever the user makes an action (calls a script) so you get the "correct answer" when you check for the cookie.
    NOTE: you can manage cookies with the CGI module.

    I bet this didn't help hehe :)
    Good luck


    : Could someone please tell me if there is a way to determine when a user
    : has left my site.
    :
    : Cheers!!
    :
    : Dave!!
    :

Sign In or Register to comment.