Forum Moderators: coopster
if (isset($_COOKIE['mycookie'])) {
echo $_COOKIE['mycookie'];
} else {
echo 'My cookie not set yet';
}Some other resources: I want to test, whether a browser (IE, Opera,...) accepts cookies.
The usual procedure is to setcookie and then to check isset.
But this is only possible on 2 pages (or after reloading the page), as is written at: [php.net...]
"If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie."
Also you could try some JS magic, so it doesn't happen on a reload, but loading an internal hidden iframe or image file, or even external JS file.
To get fancy, set cookie, load an external file at the beginning of the page, such as an empty JS file, have the original script wait, hope the browser starts gettign teh JS without finishing the html, cehck for the cookie when JS is requested, set a falg on the server to continue sending the html. But be carefull to include security timeouts.
SN
Common Pitfalls:Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires.
That said, there's a script on this page in the user notes that checks if the browser accepts cookies. Hopefully it's what you need.