leo-veio Posted March 14, 2013 Share Posted March 14, 2013 Hi, Is it possible kill a session when the browser is closed? Tks, Léo Quote Link to comment Share on other sites More sharing options...
patmap Posted March 14, 2013 Share Posted March 14, 2013 Hi, Put this code in MainForm->ExtEvents->OnBeforerender : window.onbeforeunload = function() { ajaxRequest(sender, 'SessionClosed', [] ); alert("Session Closed"); // You can remove this line. only for test }; And put this code on MainForm->OnAjaxEvent : If SameText( EventName, 'SessionClosed' ) Then Begin UniSession.Terminate( ); UniSession.UniApplication.Terminate( ); End; Work on FF, Chrome, IE Regards 5 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted March 15, 2013 Administrators Share Posted March 15, 2013 Nice tip. Thanks. BTW, this should work too: If SameText( EventName, 'SessionClosed' ) Then Begin UniSession.Terminate( ); End; 2 Quote Link to comment Share on other sites More sharing options...
maher Posted March 15, 2013 Share Posted March 15, 2013 Hi, All It's work just when MainFormDisplayMode = mfWindow !!! it's not work with MainFormDisplayMode = mfPage !!! How can I implement it on MainFormDisplayMode = mfPage ? Thanx Maher Quote Link to comment Share on other sites More sharing options...
patmap Posted March 15, 2013 Share Posted March 15, 2013 Hi, All It's work just when MainFormDisplayMode = mfWindow !!! it's not work with MainFormDisplayMode = mfPage !!! How can I implement it on MainFormDisplayMode = mfPage ? Thanx Maher Hi, No problem, Put this code in : MainForm->ClientEvents->ExtEvents->1-Ext.form.formPanel->onBeforeRender See picture Regards Quote Link to comment Share on other sites More sharing options...
patmap Posted March 15, 2013 Share Posted March 15, 2013 Hi Mr.Farshad I do not know why three posts were added. Please delete extra posts. Thanks Regards Quote Link to comment Share on other sites More sharing options...
maher Posted March 15, 2013 Share Posted March 15, 2013 Thank you patmap , شكرا it's work , but i have another problem, I used the "onbeforeunload function" to confirm Exit, window.onbeforeunload = function{ retrun "Are you sure you want to leave My system? The system will Terminate!"; } where i can put the code ajaxRequest(sender, 'SessionClosed', [] ); Thank you Quote Link to comment Share on other sites More sharing options...
patmap Posted March 15, 2013 Share Posted March 15, 2013 Thank you patmap , شكرا it's work , but i have another problem, I used the "onbeforeunload function" to confirm Exit, window.onbeforeunload = function{ retrun "Are you sure you want to leave My system? The system will Terminate!"; } where i can put the code ajaxRequest(sender, 'SessionClosed', [] ); Thank you Hi, Browsers act different in this case and you cant hope to do in all browser you can add this code Instead of the previous code: window.onunload = function() { ajaxRequest(sender, 'SessionClosed', [] ); }; window.onbeforeunload = function() { return "Click Leave this page to Session Closed."; }; But this code run on FF and dont run on Google chrome. There are not %100 safe solution for confirming ! Regards Quote Link to comment Share on other sites More sharing options...
aln02 Posted March 18, 2013 Share Posted March 18, 2013 IMHO, it is better to place this code in MainForm.Script. It works in both cases (mfPage, mfWindow) for example: function bunload(){dontleave="Are you sure? The program will be closed!";return dontleave;};function ounload(){ajaxRequest(MainForm.window, 'SessionClosed', [] );};onbeforeunload = bunload;onunload=ounload; for me, it works on FF, IE, Chrome. But Opera doesn't support both events (((. 2 Quote Link to comment Share on other sites More sharing options...
maher Posted March 19, 2013 Share Posted March 19, 2013 Hi Oleg Thank you it's working now Quote Link to comment Share on other sites More sharing options...
mehmet07 Posted December 19, 2013 Share Posted December 19, 2013 i can not working Could please send me samples ? Thank you Quote Link to comment Share on other sites More sharing options...
ChenHaibin Posted December 20, 2013 Share Posted December 20, 2013 If use this method in loginform it does not work . I use unigui 0.941024 Quote Link to comment Share on other sites More sharing options...
mehmet07 Posted December 21, 2013 Share Posted December 21, 2013 i not use login form. i use mainform. my unigui version : 0.93.0.996 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.