title: Why is only one cookie saved when live?
body: <p>I have a php script handling an incoming ajax request. It looks up some credentials from text files and if they match requirements it sets two cookies, one called username and one called creds on the client machine.</p>
  
  <p>When I do this from my local web server, all three cookies get set and I receive all the php feedback from the echoes.</p>
  
  <p>When I do this from my hosted web server the first setcookie works ("cookies","enabled") but the next two dont! However I get all the echoes confirming that php has reached the point in my script where they should be set. Any ideas please? I am thoroughly stumped.</p>
  
  <pre><code>&lt;?php
  
    //george:bloog
    //emeline:sparg
  
  
    setCookie("primacy[cookies]","enabled", time()+3600*24*30,'/');
  
  
    //convert string to summed int
    function pwdInt($pw)
    {
      $pwdIntVal = 0;
  
      for($i=0; $i&lt;strlen($pw);$i++)
      {
        $pwdIntVal = $pwdIntVal + ( ord(strtolower($pw[$i])) - 96 );
      }
  
      return $pwdIntVal;
    }
  
    //retrieve user account creation date by parsing savefile for accountCreate var
    function getACD($aUSR)
    {
      $saveFileName = "saveFiles/" . $aUSR . ".txt";
  
      echo "Fetched save successfully.&lt;br&gt;";
  
      $lines = file($saveFileName);
      foreach($lines as $line)
      {
        if( explode(":",$line)[0] == "accountCreate");
        $lineDate = explode(":",$line)[1];
        return $lineDate;
      }
    }
  
  
  
  
    //accept incoming vars
    if(isset($_POST['username']) &amp;&amp; !empty($_POST['username']))
    {
        $uN = strtolower($_POST['username']);
        $pwd = strtolower($_POST['password']);
        $found = "Invalid user";
  
  
        //test for presence in creds
        $lines = file("creds/creds.txt");
        foreach($lines as $line)
        {
            $lineName = explode("_",$line)[0];
            if($uN == $lineName)
            {
              //matched username before delimiter "_"
              $found = $lineName;
              echo "Found user, " .  explode("_",$line)[0] . " checking     password&lt;br&gt;";
  
              //check two: use int of pwd with account creation date from user save
              $usrACD = getACD($uN);
              echo $usrACD;
  
              if(  (pwdInt($pwd) * $usrACD) ==  (explode("_",$line)[1])  )
              {
                echo "Tests passed: granting access cookies";
                setCookie("uN",$uN, time()+3600*24*30,'/');
                setCookie("cred",(pwdInt($pwd) * $usrACD),     time()+3600*24*30,'/');
              }
              else
              {
                echo "Failed password check for allowed user&lt;br&gt;";
              }
            }
        }
    }
    else
    {
      echo $found . pwdInt($pwd) . "&lt;br&gt;";
    }
  
  ?&gt;
  </code></pre>