COOKIE为什么取值问题
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'If Not Page.IsPostBack Then
Dim vote_name
Dim vote_item
vote_item = Request("vote_item")
vote_name = Request("vote_name")
DataGrid1.Caption = vote_name
'==================================================================test
'Label4.Text = Response.Cookies.Item("mysite_cookie").Value
'Dim i As Integer
'For i = 0 To Request.Cookies.Count - 1
' Response.Write("name:" & Request.Cookies.Item(i).Name & "<br>")
' Response.Write("value:" & Request.Cookies.Item(i).Value & "<br>")
'Next
'If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then
' Response.Write("vote_ok is <>")
'End If
'==============================================================
'设置投票数据更新
If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then
Response.Cookies.Item("mysite_cookie").Expires = Now.AddDays(3)
Response.Cookies.Item("mysite_cookie").Value = "vote_ok"
Dim updatesqlstring As String
updatesqlstring = "update voteitem set item_count = item_count + 1 where item_id = " & vote_item
Dim updatecommand As OleDbCommand = New OleDbCommand(updatesqlstring, OleDbConnection1)
OleDbConnection1.Open()
updatecommand.ExecuteNonQuery()
OleDbConnection1.Close()
Label3.Text = "投票成功!"
Else
Label3.Text = "您已经投过票了!请查看投票结果。"
End If
'取得投票列表
Dim sqlstring As String
Dim mycommand As OleDbCommand
sqlstring = "select item_name,item_count,vt_id from voteitem where "
sqlstring += "vt_id = (select vt_id from voteitem where item_id = " & vote_item & ")"
mycommand = New OleDbCommand(sqlstring, OleDbConnection1)
Dim mydataadapter As New OleDbDataAdapter(mycommand)
mydataadapter.Fill(DataSet11, "voteitem")
Page.DataBind()
'End If
End Sub
问题:If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then 为什么取值总是不等于"vote_ok",另外,还请教能不能动态的设定COOKIE 的NAME值,防止重复投票上是怎么处理的?
'If Not Page.IsPostBack Then
Dim vote_name
Dim vote_item
vote_item = Request("vote_item")
vote_name = Request("vote_name")
DataGrid1.Caption = vote_name
'==================================================================test
'Label4.Text = Response.Cookies.Item("mysite_cookie").Value
'Dim i As Integer
'For i = 0 To Request.Cookies.Count - 1
' Response.Write("name:" & Request.Cookies.Item(i).Name & "<br>")
' Response.Write("value:" & Request.Cookies.Item(i).Value & "<br>")
'Next
'If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then
' Response.Write("vote_ok is <>")
'End If
'==============================================================
'设置投票数据更新
If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then
Response.Cookies.Item("mysite_cookie").Expires = Now.AddDays(3)
Response.Cookies.Item("mysite_cookie").Value = "vote_ok"
Dim updatesqlstring As String
updatesqlstring = "update voteitem set item_count = item_count + 1 where item_id = " & vote_item
Dim updatecommand As OleDbCommand = New OleDbCommand(updatesqlstring, OleDbConnection1)
OleDbConnection1.Open()
updatecommand.ExecuteNonQuery()
OleDbConnection1.Close()
Label3.Text = "投票成功!"
Else
Label3.Text = "您已经投过票了!请查看投票结果。"
End If
'取得投票列表
Dim sqlstring As String
Dim mycommand As OleDbCommand
sqlstring = "select item_name,item_count,vt_id from voteitem where "
sqlstring += "vt_id = (select vt_id from voteitem where item_id = " & vote_item & ")"
mycommand = New OleDbCommand(sqlstring, OleDbConnection1)
Dim mydataadapter As New OleDbDataAdapter(mycommand)
mydataadapter.Fill(DataSet11, "voteitem")
Page.DataBind()
'End If
End Sub
问题:If Response.Cookies.Item("mysite_cookie").Value <> "vote_ok" Then 为什么取值总是不等于"vote_ok",另外,还请教能不能动态的设定COOKIE 的NAME值,防止重复投票上是怎么处理的?
...全文
相关推荐
关于Jquery操作Cookie取值错误的解决方法
使用JQuery操作cookie时 发生取的值不正确,结果发现cookie有四个不同的属性,下面与大家分享下错误的原因及解决方法
解决Android webview设置cookie和cookie丢失的问题
主要介绍了解决Android webview设置cookie和cookie丢失的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
cookie设置httpOnly和secure属性实现及问题
该文档整合了cookie的httponly和secure的简介,已经设置该属性时会遇到的问题,以及设置属性的方式
js中cookie的添加、取值、删除示例代码.docx
js中cookie的添加、取值、删除示例代码.docx
cookie解决微信不能存储localStorage的问题
本文主要介绍使用cookie解决微信不能存储localStorage的问题,这里提供了代码示例,有需要的小伙伴可以参考下


