This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi,all. Currently i am facing a problem.I have a form which can be opened by only 1 user at any given moment of time.When someone else tries to open the form (opened by someone else),he shoould get an error msg informing that the form is opened by "personName".Ihave set a flag in the database if opened==Y show error msg if opened==n allow to open the form. For this i am storing the username in session var . The prob i'm facing is that when the user(after opening form) closes the browser window,the database flag stays active ie ='Y'. Can i have a window closing event so that if he closes the browser,his session will be invalidated? Or can u suggest some other way? Any help is appreciated. Thanx, Vedhas.
Vedhas You can't detect the window closing on the server side, it can only be done client side with javascript. You need to figure out a way for the javascript to communicate with the servlet on the server, an applet might do it for you. You can also have the flag expire when the current session ends too, you can detect that server side. In fact you almost have to in case for some reason the client side never lets the server know the window was closed. hope that helps
Even with javascript there is not a good way to be notified when the user closes the window, unless you provide a logout button. But that will not handle the case when the user just uses the 'x' in the upper right hand corner. Regards, Erick
There is no foolproof method with Javascript as NS4.7 does not suppport trapping of unload event and in any case the client can always disable Javascript. Do it at the server-side by trapping the session time out. Crude method ... Keep the session time-out value low, use a frame and refresh one part of the frame continuously. This will keep the session alive when the page is open. When the page is closed in the browser, it will time out quickly.