% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% Call LoadUserLevel() ' Load user level If Request.Form("submit") <> "" Then bValidPwd = False ' Setup variables susername = Request.Form("Username") spassword = Request.Form("Password") If ValidateUser(sUsername, sPassword) Then ' Write cookies sLoginType = LCase(Request.Form("rememberme")) If sLoginType = "a" Then Response.Cookies(ewProjectName)("autologin") = "autologin" Response.Cookies(ewProjectName)("username") = sUsername Response.Cookies(ewProjectName)("password") = sPassword Response.Cookies(ewProjectName).Expires = DateAdd("d", 365, Date) ' Change the expiry date of the cookies here ElseIf sLoginType = "u" Then Response.Cookies(ewProjectName)("autologin") = "rememberUsername" Response.Cookies(ewProjectName)("username") = sUsername Response.Cookies(ewProjectName).Expires = DateAdd("d", 365, Date) ' Change the expiry date of the cookies here Else Response.Cookies(ewProjectName)("autologin") = "" End If Session(ewSessionStatus) = "login" Response.Redirect "default.asp" Else Session(ewSessionMessage) = "Incorrect user ID or password" End If Else If IsLoggedIn Then If Session(ewSessionMessage) = "" Then Response.Redirect "default.asp" Else ' Check auto login If Request.Cookies(ewProjectName)("autologin") = "autologin" Then sUsername = Request.Cookies(ewProjectName)("username") sPassword = Request.Cookies(ewProjectName)("password") If ValidateUser(sUsername, sPassword) Then Response.Redirect "default.asp" End If End If End If End If %>
Login
<% If Session(ewSessionMessage) <> "" Then %><%= Session(ewSessionMessage) %>
<% Session(ewSessionMessage) = "" ' Clear message End If %><% ' Function to validate user Function ValidateUser(Username, Password) ValidateUser = False Dim CaseSensitive, AdminUsername, AdminPassword CaseSensitive = False ' Modify case sensitivity here ' Check other users If Not ValidateUser Then Set conn = Server.CreateObject("ADODB.Connection") conn.open xDb_Conn_Str sFilter = "([usuario] = '" & AdjustSql(Username) & "')" sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = conn.Execute(sSql) If Not rs.Eof Then If CaseSensitive Then ValidateUser = (rs("password") = Password) Else ValidateUser = (LCase(rs("password")) = LCase(Password)) End If If ValidateUser Then Session(ewSessionStatus) = "login" Session(ewSessionUserName) = rs("usuario") ' Load user name Session(ewSessionSysAdmin) = 0 ' Non System Administrator Session(ewSessionUserLevel) = rs("UserLevelID") ' Load user level Call SetUpUserLevel() End If End If rs.Close Set rs = Nothing conn.Close Set conn = Nothing End If End Function %>