Jump to content

Cookie Values - a basic understanding


yandoo

Recommended Posts

Hiya I'm a bit of a noob when it comes to working with cookies and have a basic question... The the background is that I am trying to build a voting system for my website with mysql & php.

 

As I understand in order to stop users from voting for the same item more than once I found i could either:

 

(1) Record the ip address with each vote (but I'm not sure this with limit multiple people who are behind a router with the same external ip address?)

(2) Require a user to login with email address (but some people wont be bothered with voting at all)

(3) Storing cookie information with each vote.

 

I've been looking at cookie guides and there's one thing that I just don't understand. When setting the cookie "Value", how is the value of the cookie initially taken?? I've read that "common values are username string and last date visit". But how would I get the username string without users logging in?? I need to get information that will uniquely identify each user. 

 

I'm sorry i must sound really stupid but if you could help me to understand that would be brilliant!

 

Thank you.

Link to comment
https://forums.phpfreaks.com/topic/278985-cookie-values-a-basic-understanding/
Share on other sites

At its simplest, you can store book ids in an array in the cookie when they vote, but before they vote you check for the book id in the cookie.  If the book id exists in the cookie then they can't vote.

 

BTW, this is very easy to circumvent, either on purpose or by accident if a user clears their cookies.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.