Application object + logged in users
-
Hi.. I am working on a web application and storing logged in user to application object. once they signout its entry will be deleted from application object - application["Loggedinusers"] ( I have stored arraylist as list of logged in users) So , once the session ends by signout or timeout user gets deleted. But it doesn't work when user closes the browser without logging out. Means the entry is not deleted from Logged in users. So next time if he logs in, " It says you are already logged in".... Can you provide me the way to resolve this. Thanks,
By: Hemant Thaker
-
Hi.. I am working on a web application and storing logged in user to application object. once they signout its entry will be deleted from application object - application["Loggedinusers"] ( I have stored arraylist as list of logged in users) So , once the session ends by signout or timeout user gets deleted. But it doesn't work when user closes the browser without logging out. Means the entry is not deleted from Logged in users. So next time if he logs in, " It says you are already logged in".... Can you provide me the way to resolve this. Thanks,
By: Hemant Thaker
See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like
function CheckBrowser()
{
, Alt+F4 , File -> Close
if(window.event.clientX < 0 && window.event.clientY <0)
{
window.open("Temp.aspx",
"Operation",'left=12000,top=1200,width=10,height=1');
}
}here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State
Cheers!! Brij Check my latest Article :A walkthrough to Application State
-
See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like
function CheckBrowser()
{
, Alt+F4 , File -> Close
if(window.event.clientX < 0 && window.event.clientY <0)
{
window.open("Temp.aspx",
"Operation",'left=12000,top=1200,width=10,height=1');
}
}here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State
Cheers!! Brij Check my latest Article :A walkthrough to Application State
Hi.. thanks, its biggest resolution so far. well.. how about calling CheckBrowser() function in master page As I am using master page. Can I use thanks,
By: Hemant Thaker
-
See, when user log out by signout or timeout then session_end get called so user gets deleted, but when user close the browser then session_end is called only when the time out expires. So when user tries just after closing the browser and try to open the application then it shows as logged in but if try to access after the session timeout then would not show because session_end will be called after timeout. So if you want to logout just after the browser close then you have to detect the browser close and logout the user by code. So for this do the following - Make an temporary page - On pageload of this remove the user from applicaton object - Now on every page of your application detect the browser close and load this page as popup with 0 size and after loading close this popup. The code for detecting the browser close is like
function CheckBrowser()
{
, Alt+F4 , File -> Close
if(window.event.clientX < 0 && window.event.clientY <0)
{
window.open("Temp.aspx",
"Operation",'left=12000,top=1200,width=10,height=1');
}
}here Temp.aspx is your temporary page. For details about Application Objects you han have a look to one of my article A walkthrough to Application State
Cheers!! Brij Check my latest Article :A walkthrough to Application State
I wouldn't use a window.open as that can be annoying and/or scary to users. I would probably use a XMLHttpRequest from the javascript since that is much less visible. Also another trick for pages that do not need to show the user anything and are just to update server-side info is set the http status code to 204. Another option is to set a cookie when they close the browser. Whenever someone comes to your site check for the "ImReallyLoggedOut" cookie before showing the message.