|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
validate right to vote
I'm trying to use cookies to check if the user is logged in but I'm totally confused about how to do this.
Where should I put the setcookie code? on the vote validation page or earlier (on the login validation page)? Basically i really need to see an example cos I've looked at the tutorials but can't figure out how to adapt it to what i need. WHat I want to do is check if they are logged in by looking for a cookie then check if they have already voted or not. I think I'm ok with reading cookies but where and how to set them is another matter. Thanks, Craig. |
|
#2
|
|||
|
|||
|
well,.....it depends on your datamodel.
are you allowing only registered members the right to vote? or are you allowing everyone? If you are allowing everyone then yes you must set a cookie after the user has voted. Normally what I do is set a cookie with the poll_id value. then check against that value if they try to vote again.
__________________
-- Jason |
|
#3
|
|||
|
|||
|
OK I understand what you say (in my case I'm using an "already voted" field in the database) but i just don't know how to set the cookie.
I have 3 pages to validate different forms registration login vote I suspect i have to start my cookies when they hit submit and pass all the validation for login. Is that right and if so how? I know the basic formula setcookie("username", "$username"); setcookie("vote_completed", "$vote_completed"); Is that right? and where exactly on my validation does it go? Sorry to ask so many questions but I've been going around in circles for ages. My current main hurdle is how can I check if the username exists and therefore if the user is eligible to vote or not. Ta, Craig. |
|
#4
|
|||
|
|||
|
well,...set the cookie when they process the form the first time,...
then the next that poll loads,...you can check to see if a cookie exists,.. PHP Code:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > validate right to vote |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|