Click here to Skip to main content
14,937,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai,
In IE9 and Firefox, if you close the browser without logging out, it still considers you logged in. And,if I log a new browser and try to log in, I still get the "User already logged in error". User sessions should end when the browser window is closed.

we don't want to raise an event like <body önunload="HandleClose()">

when the page is refreshing that time also onunload works


Pls give me a solution

Thanks & regards,
Soumya
Posted

Use a Session variable to see if the user has started a new session. If the session variable doesn't exist or doesn't contain a value, it's a new session, and the user should be forced to log back on.
   
In global.asax file edit
C#
void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown
        Session.Abandan();

    }

hope it works!
   
Hi,

I tried some code try this for your requirement.

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript">
        function f1() {
            alert(window.closed);
        }
     
     </script>
</head>
<body onunload ="f1()" >
    <form id="form1" runat="server">
    <div>
      
    </div>
    </form>
</body>
</html>


Check above code and use that code by changing some code as for your requirement.

All the Best
   
Hai all,

Thank you for your response

The solutions which u advice is all related to önunload event


we don't want to raise an event on onunload


pls give me another solution

Thanks in advance

Regards,

Soumya
   
It's very clear that there is no full proof solution for this issue except that use session timeout or client side "onbeforeunload " event.

If you are using Session Timeout with balanced time period then it would be a good solution because if your site is more secured then you can not rely very easily on client side. Some user may disable client script then jscript can create a problem.

I have seen on couple of sites that if you are refreshing the page during session then your session may kill and as per my understanding this solution on working on "onbeforeunload" event so if you don't have issue to implement this approach then you can implement this one too. Because it will for Browser close and Refresh scenarios.
But I am not sure for all browser is able to handle this event like IE6/7/8/9, Opera, FF, Chrome etc.

Thanks
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900