Cookie test/detection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
packito
Forum Newbie
Posts: 20
Joined: Mon May 19, 2003 1:53 pm

Cookie test/detection

Post by packito »

hi!

I have a voting system that only adds a vote into a poll if the user haven't voted for that choice before, based on cookies stored on the user's computer. This works fine!
But how can i make sure only users with cookie enabled browsers are allowed to vote?? I mean, how can i test if a browser is accepting cookies? :?

Any help is appreciated. Thanks!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Simple solution: set cookie, then try to read it. ;) If read was successful - browser of user in question is cookie enabled.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Those cookie based tracking systems never work. Someone can clear cookies and vote an unlimited ammount of times.

May I suggest db storage of IPs or [php_man]sessions[/php_man]. :)
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

No ultimate protection, you know ;) Different people can be behind one ip, sessions expire....
Post Reply