/    Sign up×
Community /Pin to ProfileBookmark

loggin out a user when closing the browser

Hi all,
Is there anyway i can detect the browser close event? I cannt use “onunload” event of the body because it will fire when ever i refresh the browser.

I will explain my senario so u`ll undestand this better.

Im writting a online books system where editors can login to my system and write books. There is a frontend so anyone come into my site can view all the books available.
The problem is in the backend.Some books can be writtn by two authors. So when ever a author editing his book i access denied for anyone who tyring to access that same book.So when ever the author saves the data only others can access that perticular book.

So lets assume that author has selected a book and accidently close the browser or he did it purposly. eventhough the editor leave the editing section now my system have no way of identify that. So i was thinking of catching the browser closing event and called an AJAX function to release that book from that author.

But To do this i need to catch exactly the browser closing event that fire only when a user close the browser using “X” button.

All the comments and suggestions are welcome.

Thanx in advance,

Regards,
niroshan

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieOct 13.2005 — Why dont you make you give the user an identifying value in the query string?
Copy linkTweet thisAlerts:
@niroshanauthorOct 13.2005 — Hi,

Im not quite sure what you ment by that Sorry. But if user logout or select another book this problem wont arrise. The problem comes only when the editor close the window without doing that only.

Regards,

niroshan
×

Success!

Help @niroshan 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...