TheMagician Posted July 12, 2005 Posted July 12, 2005 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. Quote
a_jam_sandwich Posted July 12, 2005 Posted July 12, 2005 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 Quote Code today gone tomorrow!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.