setcookie not working
I know there was a TONS of similar quesitons here, but I've tried already all suggestions posted in other questions, and nothing helped.
This is my function:
function makecookie($s, $d) {
if(empty($_COOKIE[@COOKIE_PATH . "[{$s}]"])) {
setcookie(@COOKIE_PATH . "[{$s}]", $d);
}
return true;
}
At the top of the document I got: ob_start();
and at the end of the document I got ob_end_flush();
.
When I try:
echo setcookie(@COOKIE_PATH . "[{$s}]", $d);
exit;
It returns 1 what means 'true'. And cookie has been 开发者_StackOverflow中文版not set.
So why does it happen?
Once the cookie is set, you can retrieve it on next page load with $_COOKIE["name of cookie"]
@COOKIE_PATH
doesn't look like valid/sensible PHP. Are you sure that isn't some sort of typo for (say) $COOKIE_PATH
?
精彩评论