Forum Moderators: coopster
if (isset($_COOKIE['name']){do something;}
be wrong somehow, because it works on my computer but not in my server and Im wondering if Im doing something wrong or ambiguos here :S
edit:
by the way I was testing now the php code because before it was being called from a ajax based js file so I didnt know exactly what the responseText was holding. But now i executed just the php file and it sais that header were sent already when i try to set the cookie in line #xx so I guess this might be the problem but still dont get why it works on my computer and not on my server :( and still dont know how to fix this :(
thanks in advance.
To get around this either re-position your setcookie statement, or use output buffering. It would be cleaner to just move your setcookie statement, as ob_buffering is a work around not a solution and can introduce its own problems.
You could also use javascript to set the cookie a a later point. With the problem that if javascript is disabled then the cookie will never get set.
If the setting of the cookie is working on one system but not on another then you need to have a look at what is different between the systems.
Are you using the javascript on your localhost, but php on the server?
Are you using javascript to set the cookie, but not allowing javascript from non-localhost's?
Are you setting the cookie domain? As if you are setting the domain as localhost then that is going to confuse your browser when getting a cookie from your server.
I assume that you mean
if (isset($_COOKIE['name']))// missing closing ) for if statement
{do something;}
;)
You were mentioning something about js disable, actually if the user disables js they cant vote(its an ajax rating system) :( so they better have it enabled but anyways js is not setting cookies here.
thanks again