vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, January 19, 2011

AVOID MULTIPLE USER TO LOGIN AT THE SAME TIME IN ASP.NET USING VB CODING

HI  friends .....
i knew so many of them looking for the solution this problem..........



Generally we all know one method to avoid this problem thats is setting seperate field in that user table,if the user enter the particular field can change in that table ,when log out agin the field comes to defaut value....But in this method we have one proble suppose the user exists apprpriately without clicking log out that is(close browser directly )..then the field cannot change ...


Next time when the user enter ..its show error ....to avoid this problem simply we have to follow addtional methods..that is we have to add session status..In that session status we have add the change query,we have to find the session state in GLOBAL.ASAX file ,in that file you have to add session state


Here the process to find GLOBAL>ASAX file...Right click ADD NEW ITEM--GLOBAL.ASAX FILE


eg:
 Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        Dim fselect As String
              select = "update Login1 set status='N' where UserId='" & Session("Username") & "'"
     sqlcmd = New SqlCommand(select, sqlcon)
end sub


Also you add follow one more steps......
In that web config file you have add the session time out....


eg:
<system.web>
     <!-- 
            Set compilation debug="true" to insert debugging 
            symbols into the compiled page. Because this 
            affects performance, set this value to true only 
            during development.


            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
    <!--<sessionState mode="StateServer" stateConnectionString=""  cookieless="false" timeout="1" />-->
    <sessionState mode="InProc" timeout ="1">
          </sessionState>
    <compilation debug="true" strict="false" explicit="true">




Now you can run the process.........
Even the user not properly exit also that table can change the value......


Further if you have any doubt contact me...i am looking forward your comments...

1 comments:

Muhammad Azeem said...

This is a nice article..
Its easy to understand ..
And this article is using to learn something about it..

c#, dot.net, php tutorial, Ms sql server

Thanks a lot..!
ri80

Post a Comment