How to make the browser closed session fails

llzzcc66 know partner Digital expert recommendation on 2018-08-10 
 
 
If the user does not click on the Web at "Exit" link, directly close the browser (or forced to close the browser processes, crashes, etc.), the server can not handle the request the user exits the site, to resolve as follows:

Mode 1: added to each page hidden iFrame, asynchronous refresh refreshed periodically way iframe page, such as once every 10S refresh, refresh request when the server is not received within a certain time user, it is considered that the user has to exit the
advantages: can determine in a short time whether the user has exited Cons: increase the number of user requests, large server resources consumed

Option 2: use cookie to save user login information, do not set an expiration time of the cookie, when closing the browser when, cookie will automatically expire
advantages: easy to deal with shortcomings : the user's browser may not support cookie, could not be achieved this way

mode 3: Add onunload event page, when you close your browser, automatically jump to the "exit" page (loginout.action)
advantages: when you exit, can timely processing drawback: when a user opens When a page, a page close any are likely to lead the user to exit the

mode 4: operation time record user per operating time (including the page refresh, submit forms, etc.), using the database jobs from time to time to check last when the operation time is greater than a certain value, it is considered that the user has exited
advantages: Either non-normal exit, capable of processing disadvantages: checking time interval is not easy to determine if the user is online, when not operated for a long time, will think that the user has to exit the

mode 5: wait for the session failed
Pros: You can not do any work Cons: Users can log in again during this time you wait

Guess you like

Origin www.cnblogs.com/guiyishanren/p/11067867.html