I have a need for a simple cookie. When a user clicks a link to vote I want the code to check for a cookie. if the value of the cookie is true, do not let the person vote (1 vote per person). Else allow the person to vote and place a cookie on their box.
My code doesn't seem to be working. Any thoughts?
VB Code:
If IsDBNull(Request.Cookies("PplsChoice")) Then Dim Cookie As New HttpCookie("PplsChoice") Dim Item As String = Request.QueryString("i") Dim cmd As New ExecuteCommand(AppSettings("cnn") & Server.MapPath("\GalleryCatalog\DataSource\TEST_auction_data.mdb")) 'update catalog table If cmd.SetData("UPDATE Catalog_tbl SET PplsChoiceTally = [pplschoicetally] + 1 WHERE ItemNumber = '" & Item & "'") Then 'append cookie to flag the computer's vote Cookie.Expires = #4/16/2004# Cookie.Values.Add("Voted", "True") Response.Cookies.Add(Cookie) lblVote.Text = "Thank you for casting your vote for People's Choice the results will be determined on " & AppSettings("Date.PplsChoice") lblVote.ForeColor = Green Else lblVote.Text = "We're sorry, your vote was not tallied, please try again. If the problem continues contact WITF to cast your vote." lblVote.ForeColor = Red End If Else lblVote.Text = "We're sorry, our records show you have already casted a vote for People's Choice." lblVote.ForeColor = Red End If lblVote.Visible = True




Reply With Quote