Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey guys

 

I have set up an intranet site with a Poll on it. Everything works fine and it records the votes in a database and that all works fine as well. The problem is I want to restrict people to only voting once. Log-in isn't an option, but I am using cookies to identify those that have voted when they open the page afresh. However the loophole is that if you vote and then press back on the browser, you can then vote again. I really don't know how to stop this happening?

 

Is it possible to capture the "back" event? How else could this be managed?

 

Any ideas would be muchly appreciated :)

 

Cheers

Ian

 

EDIT: I'm using ASP.net with vb.net code behind.

Posted

Are you checking the cookie for a vote on Page Load or just before setting the vote count? If you are checking on page load then this event will not occur when the user press's the back button on the browser.

 

Somthing like below will work regardless of pressing back

 

       ' Checking vote cookie
       If (Not Request.Cookies("Vote") Is Nothing) Then
           ' Do nothing vote already taken
       Else
           Dim HTTPCookie As New HttpCookie("Vote")
           HTTPCookie.Expires = Now.AddDays(365)
           Response.Cookies.Add(HTTPCookie)
           ' Do add vote code
       End If

 

Regards

 

Andy

Code today gone tomorrow!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...