Jump to content

Triggering php on page-close


therealwesfoster

Recommended Posts

I'm wanting to delete a user from the "whos online" part of a site once they leave the site.

 

I was thinking about triggering an AJAX call with javascript once the page is closed. But would that leave enough time for the ajax to run? Would the page wait to close until the ajax returns a succes?

 

What would be the best way to do this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/100798-triggering-php-on-page-close/
Share on other sites

Hey,

 

Depends on if you have an extensive tracking system in place.

 

One of my company sites tracks the user "everywhere" they go, so on the "list online users" page we simply check to see who has not updated the tracker say within 20 minutes and then we log them out.

 

This is also a good method becuase you could if need be log a user out directly from the db since the session is corresponding with the db.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.