Jump to content

clearing cache or something for all users


ryanmetzler3

Recommended Posts

I downloaded a script for a poll/voting kinda thing for all my site visitors a while ago and then I tweaked it a bit. It is linked to a database. It grabs the question and possible answers from one database. It also stores user votes, ip addresses, and the date they voted in a database. 

 

I went to change the question and possible answers in my poll by simply changing the options in the Database. This worked fine, but I found a big problem! If you have already voted in the poll, then it displays the results to you every time you visit the site . I assumed this was based off your IP since it is recorded in the database. So logically I thought if you cleared all the IP's in the DB, then the new question would display for every user, but to my alarm it is based off cookies. This is problem because even though I changed the question and options, if people have not cleared their cookies from the last time then the poll still displays the results even though they have not voted on the new question yet. Is there someway to clear everyone cookies or make the poll start fresh for everyone without drastically changing the code and how the entire thing works?

Edited by ryanmetzler3
Link to comment
Share on other sites

I have a poll on my website. If you vote, then it registers a cookie and displays the results. It will continue to show the results even if you refresh the page because of that cookie. My problem is if I change the question then I want it to start fresh. Unfortunately if the user has not cleared their cookies from the last time they voted, it automatically displays the results even if the question was updated. I tried something like this:

 

$_COOKIE = array();

 

this does not work because then it always clears it every time anyone visits. I just need to somehow wipe everyone's clean once when I update the question??

Link to comment
Share on other sites

I have a poll on my website. The question and answers for the poll are stored in a database. When I want to change the poll I simply change the question and answer options in the database. Here is the problem. When you vote it registers a cookie and then knows to display the results rather than the question. Like so:

setcookie("voted".$_POST['pollid'], 'yes', time()+86400*300); 
Unfortunately when I change the question the old cookies are still in place. So it is automatically showing the results to the new question even if you only already voted on the previous question. Is there a way to detect if you voted on the old poll, and clear your cookie if you voted on the old one?. Really lost on how to solve this. I was thinking something like this:
if(some constraint to distinguish old cookies maybe a time-stamp?){
$_COOKIES = array();
}
Edited by ryanmetzler3
Link to comment
Share on other sites

"voted".$_POST['pollid']

 

 

that fact that there's a pollid that the cookie is keyed to, implies that the question, answers, and poll results also use the pollid.

 

you would create a new/different poll by inserting the new question/answers using a different pollid, that would then also store the results and make a different cookie name for that new pollid. i'm betting the script has a 'create/insert' new poll interface that would do this for you.

Edited by mac_gyver
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.