PHP Session et Cookies: Vérifier si les cookies sont activés

 
<?php
    if(!isset($_GET['testcookie'])) {
        setcookie("testcookie", "test value");
        header("Location:  {$_SERVER["PHP_SELF"]}?testcookie=1");
        exit;
    } else {
        if(isset($_COOKIE['testcookie'])) {
            setcookie("testcookie");
            echo "You have cookies enabled";
        } else {
            echo "You do not support cookies!";
        }
    }
?>
  
  
 
<?php
 
    if(!isset($_GET['testcookie'])) {
 
        setcookie("testcookie", "test value");
        header("Location:  {$_SERVER["PHP_SELF"]}?testcookie=1");
        exit;
 
    } else {
 
        if(isset($_COOKIE['testcookie'])) {
 
            setcookie("testcookie");
            echo "You have cookies enabled";
 
        } else {
 
            echo "You do not support cookies!";
 
        }
    }
 
?>
  
  

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>