View Single Post

  #17 (permalink)  
Old 05-09-2008
C. (http://symcbean.blogspot.com/)
 
Posts: n/a
Default Re: How to detect user leaving site?

On 9 May, 12:05, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.com> wrote:
> Piotr schreef:
>
>
>
> > Erwin Moller wrote:
> > >>>> after the user left the site and
> >>>>> returned.

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

>
> > Part refer is useful, is the moment when user *returns*.
> > Not when he's leaving. I believe that Sebastian wants to detect
> > *returning* clients (so he wont display welcome to them), not leaving ones.

>
> > If Sebastian sees that the users was on his site recently (session is
> > already there), but the refer does not point to his site, then he can
> > guess, that the user was on a site X and from the site X returned to his
> > site.

>
> > Ofc, you need to assume that session is stored in cookies, users accepts
> > and keep them, and that he returns by clicking on link.
> > But as for such trivial thing, as hiding welcome message, you can do so,
> > without risking it will spoil browsing experience for anyone.

>
> > best regards
> > Piotr N

>
> Hi Piotr,
>
> All clear, I see now what you ment earlier.
> I was focussed on the 'detecting leaving the site' part of the question.
>
> Regards,
> Erwin Moller


....but getting back to the original post:

> after some testing found that sometimes the
> old session data remained even after the user left the site and
> returned


Maybe - it depends on your definition of 'left the site'.

Sessions work by getting reaped when they've not been active for a
while (or when you explicitly destroy them in your code). OTOH the
session cookie will be retained for as long as the browser session is
active.

How you go about addressing your problem depends on what you are
trying to achieve:

e.g. if you want to see how users get in your site before abandoning
it, then the best solution might be to write your own session handler
which also logs the current URL then migrate this data to a log when
the session is reaped.

If you merely wish the sessions to expire quicker then adjust the
session.gc_ parameters

C.
Reply With Quote