Hey!
I use the following code to check to see if cookies are enabled. If they are enabled, the script will redirect to another page. If they are not enabled, it will redirect to a page that will tell the user to enable cookies.
I get this error and it only redirects if cookies are enabled. If they are not, it does not display cookies.php
PHP Notice: Undefined index: cookie_checked in /var/www/vhosts/mydomain.com/httpdocs/index.php on line 4
PHP Code:
<?php
session_start();
if ($_SESSION['cookie_checked'])
{
if ($_COOKIE['cookie_checked'])
{
header("Location: login.php");
} else {
header("Location: cookies.php");
}
} else {
$_SESSION['cookie_checked'] = 1;
setcookie('cookie_checked', 1);
header("Location: $_SERVER[PHP_SELF]");
}
?>
Bookmarks