Classic ASP : Multiple user log in problem

Viewed 24

I have created simple login system using Classic ASP. Username and password both are stored in database.

My problem :

● user 1 and user 2 are logged in at same time ( but, user 2 little bit late around 5 to 10 seconds )

● when user 1 refresh his browser, his account accidentally changed to user 2's account.

how to solve this problem?

Below is my code

<%  
basePath  = Request.ServerVariables("APPL_PHYSICAL_PATH")

If Request.Form("login_button") = "ENTER" Then
    if Request.Form("ID") = "" Then
        Response.Redirect("login.asp?Error=You+didn't+enter+any+username.")
    Else
        Set conn = Server.Createobject("ADODB.Connection")
            conn.open "PROVIDER=Microsoft.JET.OLEDB.4.0;DATA SOURCE=" & basePath & "/+++/+++++.mdb"
    
            MySQL="SELECT * FROM users WHERE id = " & Request.Form("ID") & ""
        Set MyRs=Conn.Execute(MySQL)    
            if Not MyRs.Eof Then            
                If Request.Form("password") = MyRs(2)  Then
                    Application("id") = MyRs(1)
                    Session("id") = MyRs(1)
                    Response.Redirect("main.asp")
                Else
                    Response.Redirect("login.asp?Error=You+have+entered+an+invalid+username+or+password.")
                End If
            Else
                Response.Redirect("login.asp?Error=You+have+entered+an+invalid+username+or+password.")
            End If      
        conn.close
        Set conn = Nothing
    End If
Elseif Request.Form("reset_button") = "RESET" Then          
    Response.Redirect("login.asp")          
End If
%>
0 Answers
Related