Changing cookie expiration time.

Discussion in 'PHP' started by Nintendo, Mar 29, 2007.

  1. #1
              if (!$_COOKIE['xxxxxx']) {
                  setcookie('xxxxxx', '1', 1143964800);
              } elseif ($_COOKIE['xxxxxx'] < 3) {
                  setcookie('xxxxxx', $_COOKIE['xxxxxx'] + 1, 1143964800);
    PHP:
    What do you change this code to so the cookie expires when the browser gets closed? That code is set to April 2nd, 2006.
     
    Nintendo, Mar 29, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Remove the third argument at all.
    
    setcookie('xxxxxx', '1');
    
    PHP:
     
    nico_swd, Mar 29, 2007 IP
  3. Wyla

    Wyla Well-Known Member

    Messages:
    924
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    140
    #3
    This should last until window is closed.
    
    setcookie("name", "value", 0);
    
    PHP:
     
    Wyla, Mar 29, 2007 IP