/    Sign up×
Community /Pin to ProfileBookmark

Detecting dead users

Hi,

I know there are the event handlers onBeforeUnload and onunload, which work great 90% of the time.

But what would happen if a user who was in the system had a power cut? Would it then be down to the database that stores who is logged in to go through logging users out who havent done anything for a while?

Or could you use the PHP function ‘exec’ to ping the users IP address and if there is no response, log them off?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 12.2011 — You may use a server-side session cookie which expires when the user leaves the site. Should work even if the system has a power cut.
Copy linkTweet thisAlerts:
@imperium2335authorMay 12.2011 — Would my way work though? As the CGI stuff looks very complicated :/
Copy linkTweet thisAlerts:
@KorMay 12.2011 — Would my way work though? As the CGI stuff looks very complicated :/[/QUOTE]
Not more complicated than a client-side solution. But most of the time better:

http://www.tizag.com/phpT/phpsessions.php
Copy linkTweet thisAlerts:
@imperium2335authorMay 12.2011 — So PHP would destroy a session if a user had a powercut or otherwise left the site? I know abit about these so I could use them, but I thought they persisted for a while after the user vanished?
×

Success!

Help @imperium2335 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...