How to detect user leaving site?

This is a discussion on How to detect user leaving site? within the PHP Language forums, part of the PHP Programming Forums category; Can this be done without client-side scripting? I thought sessions might be the answer but after some testing found ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 5 Days Ago
sebastian
 
Posts: n/a
Default How to detect user leaving site?

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?
Reply With Quote
  #2 (permalink)  
Old 5 Days Ago
Erwin Moller
 
Posts: n/a
Default Re: How to detect user leaving site?

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).

Regards,
Erwin Moller
Reply With Quote
  #3 (permalink)  
Old 5 Days Ago
Piotr
 
Posts: n/a
Default Re: How to detect user leaving site?

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.

@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
  #4 (permalink)  
Old 5 Days Ago
Jerry Stuckle
 
Posts: n/a
Default Re: How to detect user leaving site?

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).
>
> Regards,
> Erwin Moller
>


And even Javascript doesn't necessarily tell you. Closing the browser,
for instance, will not execute javascript.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #5 (permalink)  
Old 5 Days Ago
sebastian
 
Posts: n/a
Default Re: How to detect user leaving site?

> Regards,
> Erwin Moller


Something tells me that you are not, in fact, Erwin Moller. If not,
please do not reply to my posts. The fact that you would masquarade as
another user is ridiculous. Pitiful.

- Sebastian

Reply With Quote
  #6 (permalink)  
Old 5 Days Ago
Piotr
 
Posts: n/a
Default Re: How to detect user leaving site?

sebastian wrote:
>> Regards,
>> Erwin Moller

>
> Something tells me that you are not, in fact, Erwin Moller. If not,
> please do not reply to my posts. The fact that you would masquarade as
> another user is ridiculous. Pitiful.
>
> - Sebastian
>


^^

That kinda made my day :)

best regards
Piotr N
Reply With Quote
  #7 (permalink)  
Old 5 Days Ago
Lars Eighner
 
Posts: n/a
Default Re: How to detect user leaving site?

In our last episode,
<e892bde7-636a-4100-b395-9a0020a92a06@b1g2000hsg.googlegroups.com>, the
lovely and talented sebastian broadcast on comp.lang.php:

> Can this be done without client-side scripting?


No.

Unless someone develops a psychic server.

--
Lars Eighner <http://larseighner.com/> usenet@larseighner.com
Countdown: 256 days to go.
Reply With Quote
  #8 (permalink)  
Old 5 Days Ago
Jerry Stuckle
 
Posts: n/a
Default Re: How to detect user leaving site?

sebastian wrote:
>> Regards,
>> Erwin Moller

>
> Something tells me that you are not, in fact, Erwin Moller. If not,
> please do not reply to my posts. The fact that you would masquarade as
> another user is ridiculous. Pitiful.
>
> - Sebastian
>
>


That is the real Erwin Moller.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #9 (permalink)  
Old 5 Days Ago
sebastian
 
Posts: n/a
Default Re: How to detect user leaving site?

>> That is the real Erwin Moller.

Ok, thanks for the clarification. The email address just looked
suspicious. =)

>> 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.

Great, I'll try that out then.

>> 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 just to display a welcome message, so no problem there.

>> 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).

Right. Well, thanks for all of the suggestions.

Regards,
- Sebastian


Reply With Quote
  #10 (permalink)  
Old 5 Days Ago
Piotr
 
Posts: n/a
Default Re: How to detect user leaving site?

sebastian wrote:
>>> 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.
>
> Great, I'll try that out then.


Just to make sure we talk about the same. Refer header will contain the
other site url, if users comes from other site. If he hits back button
it won't work. Only with links.

best regards
Piotr N
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:35 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0