If e.Path = "logon.htm"
'验证用户名和密码
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password") Then
Dim Verified As Boolean
'用于标记用户是否通过了身份验证
UserName = e.PostValues("username")
Password = e.PostValues("password")
If
UserName = "张三" AndAlso Password = "888"
Then '实际使用的时候,请改为从数据库读取用户名和密码进行比较
Verified = True
ElseIf
Username = "李四" AndAlso Password="999"
Then
Verified = True
End If
If Verified Then
UserID = Rand.NextString(16) '生成随机用户ID
UserName = EncryptText(UserName,"123","123") '将用户名加密.
Dim dr As DataRow = UserTable.Find("UserName = '" & UserName & "'")
If dr IsNot Nothing
Then
'如果是重复登录,删除以前的登录信息
dr.Delete()
End If
dr = UserTable.AddNew()
dr("UserName") = UserName
dr("UserID") = UserId
dr("ActiveTime") = Date.Now
'记录登录时间
wb.AppendCookie("username",UserName) '将用户名和密码写入cookie
wb.AppendCookie("userid",UserID)
wb.InsertHTML("<meta http-equiv='Refresh' c>") '直接跳转到首页
e.WriteString(wb.Build) '生成网页
Return
'必须的
End If
End If