Prevent user from closing Firefox

c#, firefox

Solution

Every user should have a session, if you are using authentication. Sessions can be configured to expire. All you need to do is just to handle an appropriate session expire event.

Do not look for any hack to handle a browser exit event - it is a dangerous path:

- Everybody would hate it, and there is no chance you can make it reliable, i.e. working in newer versions of browsers, supporting many browsers on different OS etc

- This may work in Firefox Mozilla (sample), but may not work in IE or Chrome

- Application can be killed by OS, so browser events will not get a chance to fire and your handling code will not work

Problem

I absolutely need a user to log out of a website which she/he uses to access our database. If one doesn't log out, and simply closes the browser, the system locks the username for an hour. I did not implement it, it's just the way it works. I thought to write a simple C# program that would somehow detect whether the user logged out, and if not, prevent them from closing the browser. 1) Is there Firefox API, or any other way to read the website content in firefox.exe process? 2) When a user hits 'X' to close the browser, is it possible to abort the termination of firefox.exe process? (probably this is the deal-breaker question). I would appreciate any hints. Thanks!

Original source

Related problems