Solved

ON EXIT

Posted on 2004-08-07
6
182 Views
Last Modified: 2008-03-06
I need to know when the user close my page (without logging of), Is there any way to do this in PHP?

Thanks in advance
0
Comment
Question by:ferassh
6 Comments
 
LVL 4

Accepted Solution

by:
BrianPap22 earned 25 total points
ID: 11742145
Absolutely not.  PHP is a pure server-side language.  HTTP is a stateless protocol, so it only communicates with the browser whenever they request a page.  You will not know when they close the page.

You might try Javascript, which is a client-side language.
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 25 total points
ID: 11742366
The only way you can do this is by launching a popup in the onunload body event which runs a small script to handle telling you that they have closed the page however i strongly advise against this as it can be very annoying from the users pespective.

In php it is usually handled with timeouts, if a user is inactive for more then 2 minutes for example they can be classed as no longer browsing the site.
0
 
LVL 2

Expert Comment

by:leeprovoost
ID: 11744477
what do you want to achieve? perhaps there's another solution for your problem :-)
0
 
LVL 4

Expert Comment

by:macgruder
ID: 11745319
have the page constantly refresh itself through Javascript every 10 secs or so
when the page connects have it write to a database some page id, and timestamp
have the database regularly checked
if the page id doesn't appear in the db within a certain timestamp then it's probably no longer connected

This is a solution to what you are trying to do, but not saying that it's a good idea :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JQuery Search Filter 2 71
Multi line FPDF footer: 3 27
How do I remove "" from json_encode 5 22
Set a time limit on Wordpress Cookie function. 3 14
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question