以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  有关cookies  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=110895)

--  作者:fubblyc
--  发布时间:2017/12/11 23:44:00
--  有关cookies
蓝老师,登录进来,正常的时候都有带有用户名cookies,但是刚才就没有了。按退出(带有清除cookies),进入页面还是直接进入首页,而不是到登录页面

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20171211234140.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2017/12/11 23:49:00
--  
给出具体可以分析的代码
--  作者:fubblyc
--  发布时间:2017/12/12 0:01:00
--  
Dim wb As New  WeUI
Dim Verified As Boolean \'用于标记用户是否通过了身份验证
Dim UserName As String = e.Cookies("username") \'从cookie中获取用户名
Dim Password As String = e.Cookies("password") \'从cookie中获取用户密码
If e.Path = "logon.htm" Or  e.Path = "logonjl.htm" \'如果是通过登录页面访问,从PostValues即可中提取用户名和密码
    If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then
        UserName = e.PostValues("username")
        Password = e.PostValues("password")
    End If
End If


logon的代码:
wb.AddPageTitle("","pageheader","智慧工场","致力提升效率,倍增业绩")
If e.PostValues.ContainsKey("username") AndAlso e.PostValues.ContainsKey("password")  Then \'判断是否是验证失败后的重新登录
    wb.AddTopTips("","toptip1","用户名或密码错误!").msec = 2000 \'如果用户通过登录按钮访问,则给用户一个2秒的提示.
End If
wb.AddForm("","form1","logon.htm")
With wb.AddInputGroup("form1","ipg1")
    .AddInput("username","用户名","text")
    .AddInput("password","密码","password")
End With
With wb.AddButtonGroup("form1","btg1",True)
    .Add("btn1", "登录", "submit")
End With

e.WriteString(wb.Build) \'生成网页


exit 的代码
Dim e As RequestEventArgs = args(0)
Dim wb As New weui
wb.DeleteCookie("username") \'清除cookie中原来的用户名和密码
wb.InsertHTML("<meta http-equiv=\'Refresh\' c>") \'那么直接跳转到登录页面
e.WriteString(wb.Build)



--  作者:有点甜
--  发布时间:2017/12/12 9:25:00
--  

1、你试试这样写

 

e.Cookies("username") = Nothing

 

2、你httprequest,是怎么处理跳转的?贴出详细代码。或者你加入msgbox弹出对应的值看看。


--  作者:fubblyc
--  发布时间:2017/12/16 10:49:00
--  
恩恩。甜老师,
好像是密码列有空的值导致的。我都加上就好了。