Cookies
Hello,
I've created a cgi script to run a poll on my site. I use IP checking to see if someone has already voted. But if people are accessing my poll from behind a firewall, then they may have the same IP address. So instead of using IP check, I want to use cookie check.
Does any one know how to do this? Or can you at least tell me where to find information to do this?
Thanks.
http://www.ravelly.com - Free Message Boards
merlin posted this at 12:52 — 21st April 2001.
They have: 410 posts
Joined: Oct 1999
using cgi with perl:
setting two different cookies:
use strict;
use CGI qw(:standard);
use CGI::Cookie;
my $title = "cookie1name";
my $storycookie = "cookie2name";
my $titlecookie = cookie(
-NAME => $titlecookiename,
-VALUE => "$list{'title'}",
-PATH => '/',
-EXPIRES => "+60d",
);
my $storycookie = cookie(
-NAME => $storycookiename,
-VALUE => "$list{'story'}",
-PATH => '/',
# -DOMAIN => 'localhost',
-EXPIRES => "+60d",
);
print "Set-Cookie: $titlecookie\n";
print "Set-Cookie: $storycookie\n";
in this example i put the userinput of form-field 'title' and 'story' into two cookies. if they come back to my site, the input is already there, using:
my ($titlecookie, $storycookie);
$titlecookie = $query->cookie("cookie1name");
$storycookie = $query->cookie("cookie2name");
if you wanna know, what -path, -expires stands for, read this FAQ.
for more information, try the cookiecentral
good luck with baking. i needed quite a long time to get them ready, but know, i really like them!
merlin posted this at 12:56 — 21st April 2001.
They have: 410 posts
Joined: Oct 1999
i'm not sure, if cookies are the right way for your problem?
don't forget, user can ignore or delete your cookies, with that, they'd be able to vote several times for the poll. but i'm not sure, if there is another way to prevent that.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.