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)
msgbox(e.cookies("path"))
wb.InsertHTML("<meta http-equiv='Refresh' content='0; url=/" & e.cookies("path") & "'>")
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
End If
Else '其它页面从Cookie提取登录信息进行验证
UserName = e.Cookies("username") '从cookie中获取用户名
UserID = e.Cookies("userid") '从cookie中获取 随机ID
Dim dr As DataRow = UserTable.Find("UserName = '" & UserName & "'")
If dr IsNot Nothing AndAlso dr("UserID") = UserID Then '如果通过验证,更新活动时候,继续访问其它页面.
dr("ActiveTime") = Date.Now '更新活动时间
Else '如果验证失败
wb.AppendCookie("path", e.path) '将用
wb.InsertHTML("<meta http-equiv='Refresh' content='0; url=/logon.htm'>") '那么直接跳转到登录页面
e.WriteString(wb.Build) '生成网页
Return '必须的
End If
End If