Jump to content

cookie question


darkcarnival

Recommended Posts

hi,

i want to improve the ratng system i have on my site.

right now no matter what item you vote for the same cookie will be created overwritting the last value, and i want to change that.

what i want to so is name the cookie based on the id of the item.

i tried to that but the cookie isnt being read. it'll clamin the cookie doesnt exist even though it was creayted successfully.

cant show any code since i had to revert to to the old system to prevent any mass rating that it would cause.
Link to comment
Share on other sites

how are you setting the cookie.  If you don't set the expire parameter, then the cookie will expire when the session is ended.  Consequently, upon return to the site, the cookie will not exist.

setcookie ( string name [, string value [, int expire [, string path [, string domain [, bool secure]]]]] )

time()+60*60*24*30 (for the expire parameter) will set the cookie to expire in 30 days. If not set, the cookie will expire at the end of the session (when the browser closes).

for more info see http://us3.php.net/manual/en/function.setcookie.php
Link to comment
Share on other sites

i use ob and ob_end_flush  ;)

and yes the session limit is set to last 24 hours

just to give you some code that i can remember:

[code]            $currtime = time() + (86400);
            setcookie("metalrate$id", $id, $currtime, "/", "metalstation1.com", 0);[/code]

that is not the problem, though this part is:

[code]if(isset($_COOKIE['metalrate$id']) == $id){
$voted = true;
}else{
$voted = false;
}[/code]

any ideas on this?
Link to comment
Share on other sites

why create multiple cookies????? all those cookies will be sent separately

have a look at this [url=http://uk.php.net/manual/en/function.setcookie.php]http://uk.php.net/manual/en/function.setcookie.php[/url] and pay particular attention to example 3.
Link to comment
Share on other sites

no they wont sadly.

in further test of this method it overwrote the last value. i realized that after a user figure it out and exploited the rating system.

so making a new cookie for each rate is needed to ensure users dont abuse the rating system or at least not so often as one has or can.
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.