Dear Googler,
In this post, i explain how to prevent multi user login in web application. Here we are done some basic step. That is in the user table we add the "STATUS" Filed and then if the user Enter the web application the STATUS will be changed "1" and then the user properly click the logout button " We will change the STATUS as "0" using the Logout click button Event. Other wise the user click the Browser
close button. So the web application closed but the STATUS will not changed to "0". So the user not able to login the web application again. So what we did this type of criteria,
In our ASP.Net give the solution for that, it is given below
First We add the Global.asax file. The file content is Given below,
<%@ Application Language="VB" %>
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace ="System.Data.Sqlclient" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
// Here you write your Sql Code
End Sub
</script>
In the Session_End Event we Write the Sql Update Query. In the Session_End Event occurs when all the session are clear that time the event Fire. So When the user click the Browser close button. After "60" sec the Status Changed.
With Regards,
S.Prakash.
In this post, i explain how to prevent multi user login in web application. Here we are done some basic step. That is in the user table we add the "STATUS" Filed and then if the user Enter the web application the STATUS will be changed "1" and then the user properly click the logout button " We will change the STATUS as "0" using the Logout click button Event. Other wise the user click the Browser
close button. So the web application closed but the STATUS will not changed to "0". So the user not able to login the web application again. So what we did this type of criteria,
In our ASP.Net give the solution for that, it is given below
First We add the Global.asax file. The file content is Given below,
<%@ Application Language="VB" %>
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace ="System.Data.Sqlclient" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends.
// Here you write your Sql Code
End Sub
</script>
In the Session_End Event we Write the Sql Update Query. In the Session_End Event occurs when all the session are clear that time the event Fire. So When the user click the Browser close button. After "60" sec the Status Changed.
With Regards,
S.Prakash.
but what happen when user close the tab?
ReplyDeleteDear aliasgar,
DeleteKindly see the last sentence of the blog:
In the Session_End Event we Write the Sql Update Query. In the Session_End Event occurs when all the session are clear that time the event Fire. So When the user click the Browser close button. After "60" sec the Status Changed.
It would be answer for your question.