Is this thing On? (Cookies)

Results 1 to 3 of 3

Thread: Is this thing On? (Cookies)

  1. #1
    Join Date
    Dec 1969
    Posts
    197

    Default Is this thing On? (Cookies)

    This is a simple voting page. It is supposed to deposit a cookie on the user machine that gives the month for the last vote. It is depositing the cookie with a value of 1, check out the code below.<BR><BR>if lastvote = curmonth then<BR> <BR> Response.Write("You are only allowed one vote per month. Please wait to next month and vote again.")<BR><BR>else<BR><BR> updateSQL = "update tbl_co_employees set vtally = vtally + 1 where id = " & id<BR> db(updateSQL)<BR> <BR> tempRSSQL = "select * from tbl_co_employees where id = " & id<BR> set tempRS = dbRS(tempRSSQL)<BR><BR> strMessage = "Your vote has been cast for: "<BR> strMessage = strMessage & tempRS("fullname")<BR><BR> Response.Write(strMessage)<BR> <BR> Response.Cookies("lastvote")=month(date)<BR> Response.Cookies("lastvote").expires = dateadd("m",1,date)<BR><BR> end if<BR><BR>The problem is, it is not evaluating the current month equal to the month in the cookie, which it should be. Request.cookies("lastvote") returns a 1. And month(date) returns a 1.<BR><BR>Yaargh! I am thinking maybe it has something to do with the data types, perhaps one of them is being seen as an integer and one as a character of some sort?<BR><BR>Thoughts?

  2. #2
    Join Date
    Dec 1969
    Posts
    96,118

    Default Cookies are *ALWAYS* strings...

    *ALL* values retrieved from REQUEST.xxx(yyy) are always strings.<BR><BR>So convert it to an integer before testing it vs. a number, such as a month number.<BR><BR>&#060;%<BR>cookieMonth = CInt( Request.Cookies("lastvote") )<BR>%&#062;<BR><BR>See if that helps.<BR><BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    197

    Default RE: Cookies are *ALWAYS* strings...

    Thanks Bill, you&#039;re a stud.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •