|
-
Feb 3rd, 2004, 01:26 PM
#1
Thread Starter
Lively Member
how can i check for cookies
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
Jason Meckley
Database Analyst
WITF
-
Feb 3rd, 2004, 01:29 PM
#2
Hyperactive Member
Try this instead
VB Code:
If len(Request.Cookies("PplsChoice")) <1 then
' Noo cookie
end if
I'm pretty sure its the isDBNull method that is not working. You can use isNothing() instead of len call
-
Feb 3rd, 2004, 02:45 PM
#3
Thread Starter
Lively Member
this works if there is no cookie, but once there is a cookie I get a type mismatch error.
Jason Meckley
Database Analyst
WITF
-
Feb 4th, 2004, 08:24 AM
#4
Thread Starter
Lively Member
I found code that wouldn't error out.
VB Code:
If request.cookie("PplsChoice") is Nothing then
Jason Meckley
Database Analyst
WITF
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|