?
Solved

ON EXIT

Posted on 2004-08-07
6
Medium Priority
?
184 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 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