setCookie not working in IE

Discussion in 'PHP' started by hawkseye, Jan 4, 2006.

  1. #1
    The piece of code below works fine in firefox but doesnt work in IE. can anyone tell me whts the solution to this.

    <?php
    if (isset($_COOKIE["imtcookie"])){
    $head = "includes/header1.php";
    }
    else{
    $expiry = time()+ 30;
    setcookie("imtcookie", "", $expiry);

    $head = "includes/header2.php";
    header("Set-Cookie: imtcookie=present; expires=$expiry");
    }
    ?>
     
    hawkseye, Jan 4, 2006 IP
  2. hawkseye

    hawkseye Peon

    Messages:
    10
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    if (isset($_COOKIE['imtcookie'])) {
    $head = "includes/header1.php";
    }
    else {
    $expiry = time()+60;
    setcookie("imtcookie", "present", $expiry);
    $head = "includes/header2.php";
    }
    ?>


    Well this works. I think the problem was "present" when i gave the value for the second field and removed the line
    <?
    header("Set-Cookie: imtcookie=present; expires=$expiry");
    ?>

    it started working
     
    hawkseye, Jan 4, 2006 IP