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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
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 ================== |
|
|||
|
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 |
|
|||
|
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. |
|
|||
|
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 ================== |
|
|||
|
>> 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 |
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|