View Single Post

  #14 (permalink)  
Old 05-09-2008
Erwin Moller
 
Posts: n/a
Default Re: How to detect user leaving site?

Piotr schreef:
> Erwin Moller wrote:
>> sebastian schreef:
>>> Can this be done without client-side scripting? I thought sessions
>>> might be the answer but after some testing found that sometimes the
>>> old session data remained even after the user left the site and
>>> returned. Just had an idea, though. Perhaps I could access the users
>>> Referrer header?

>>
>> Hi Sebastian,
>>
>> I think you cannot detect this without JavaScript.
>> If somebody goes somewhere else, your server is not notified.
>> You can only try this via JavaScript.
>>
>> Referer:
>> And I don't see how the Referer header can help you out.
>> It is send to the next site (if send at all).
>>
>> Session:
>> No go either.
>> A Session is nothing more than a piece of data on the server that is
>> linked to a certain visitor via a PHPSESSID (via cookie/url/form).
>> I don't see how they can help you with this.
>>
>> So bottomline, bad luck.
>> You need JavaScript (or some other clientside technology, like an JAVA
>> applet).

>
> Correct me if I'm wrong, but if user left his site, and then returned
> refer would point to the other site. So detecting refer value could
> possibly help the problem.


Hi Piotr,

I think you are wrong. ;-)
Or I miss something completely in this discussion.

Please check the answer I wrote to Sebastian for details.
And, of course, feel free to correct me/explain to me how to use the
referer header in a usefull way to detect a user leaving the site. I
still don't see how.

Regards,
Erwin Moller

>
> @Sebastian
> Refer it's send by the user, so can't be trusted. You can use it
> to improve the functionality of the site, but don't use it to any
> critical checks (like access controll ect.).
>
> It's also possible, that refer will be empty, when user types in the url
> or opens new window in 'new tab' (not sure about that though).
>
> best regards
> Piotr N

Reply With Quote