Solved

ON EXIT

Posted on 2004-08-07
6
178 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress Query 1 35
session dropped in IE 10 22
SQL inner join confusion 15 22
two tables one button 11 20
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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 …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now