PHP program webpage close event-php Tutorial

Source: Internet
Author: User
PHP program can have webpage close event User login can write logs
How to use PHP to query and write logs when a user leaves (closes the webpage)


Reply to discussion (solution)

Should not

This can only be judged by js and passed to php for processing.

Php cannot be detected.

When you close your browser, you can trigger the window. onbeforeunload event. you only need to do something in this event...

Listen to events with js, and then request the php interface. If php is used separately, it cannot be detected.

If the execution has been completed, no.
The connection_aborted function can be used in execution to determine

It turns out that the browser is not directly closed and how to record the exit log.
I don't think JS works either. If there are multiple windows, how do you know if it is the last window? if it is not the last window, it is not the exit. You can change your mind to update the user status during each operation: The Last activity time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.