Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

ON EXIT

Posted on 2004-08-07
6
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Accepted Solution

by:
BrianPap22 earned 100 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 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

648 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