Print Page | Close Window

Need A Cookie

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10796
Printed Date: 29 March 2026 at 7:01pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Need A Cookie
Posted By: Susan0722
Subject: Need A Cookie
Date Posted: 08 June 2004 at 10:52pm
I am so new to this asp stuff and I am really in need of a cookie code to add to a form I have.

I want to restrict users to filling in the form only once as this is a vote for a contest. I only want people to be able to vote once.
After they hit submit they will see a confirmation page listing thier votes. But if they go back to the form and try to vote (hit submit) again, I would like them to be directed to a page that tells them they have already voted.

Someone please help, I don't know how to write this stuff, and don't even know where to put it for that matter.

I created the form in Frontpage and it is connected to a .mdb Access 2000 database. The database is collecting the ip addresses so if the code could be to exclude ip address that would be great.

Here's the link to the page I need to put it in. http://www.horseplaycentral.com/PHnewfoals2004voting.asp - http://www.horseplaycentral.com/PHn...s2004voting.asp

Thank you so much in advance, I don't have time to read a tutorial I just need someone out of the kindness of their heart to post a simple script that will do what I need it to and tell me where I am suppose to copy and paste it to. Thanks!


-------------
Pay for your copy of WebWIZ, it's worth it and you know it!



Replies:
Posted By: Phat
Date Posted: 08 June 2004 at 11:39pm
To write a cookie use
Response.Cookies("CookieName")("PollID") = True
and to read a cookie use
Request.Cookies("CookieName")("PollID")

So you will need somting like

If Request.Cookies("CookieName")("PollID") Then
    'User cannot vote
Else
    'User can vote
End If

It is bit hard to tell you were to exacly put it without seeing the code.
Check out http://webwiz.net/asp/sample_scripts/weekly_poll_script.asp - http://webwiz.net/asp/sample_scripts/weekly_poll_script .asp

It has the feature you want so it just a matter of viewing how borg has done it and copy that system.



Posted By: Semikolon
Date Posted: 09 June 2004 at 3:46pm
doing IP blocking is in most cases not necessary, as dialup, and some broadband users get a new IP every time they connect to the internet. then they can jst reconnect and vote again, and some other users will get their IP and will be unable to vote.

but there are no ways it is possible to restrict votes to one per user..


Posted By: Mart
Date Posted: 09 June 2004 at 3:51pm
The best way IMHO is to force the user to be logged in and only allow 1 vote per account, and requiring account activation via. email


Posted By: Susan0722
Date Posted: 09 June 2004 at 4:24pm

Semi, there must be away, how about checking the email address?  I realize some folks can take advantage of the system, so I guess I am just keeping the honest folk honest.

Mart, It's to late for me to run this out of my forum, as the voting has already started.  The votes go into a database, I can see the ip addresses and the email addresses that are entered.

So I suppose I will have to sort the votes by hand.

I think Phat is on to something here, and I had another code sent to me by someone on another board.  But I am not sure where to put it.

This is it:  

<%
'-- set the cookie
response.cookies("completedForm") = true

'-- read the cookie
varFormStatus = request.cookies("completedForm")
%>

 



-------------
Pay for your copy of WebWIZ, it's worth it and you know it!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net