title: Execute cURL via PHP shell_exec() return different response than Execute cURL via Command Line
body: <h1>I ran</h1>
  <p>a cURL on my Terminal</p>
  <p><strong>Note</strong> : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7</p>
  <pre><code>curl -c session_cookies.txt &quot;https://login.uat.site.be/openid/oauth/authorize?client_id=site&amp;state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&amp;nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&amp;response_type=code&amp;claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D&quot; 2&gt;/dev/null| curl -v -b session_cookies.txt -L -H &quot;Content-Type: application/x-www-form-urlencoded&quot; -v -d 'j_username=manager-sitelogin@gmail.com&amp;j_password=site1' &quot;https://login.uat.site.be/openid/login.do&quot; 2&gt;&amp;1 &gt;/dev/null | grep Location | grep code=
  </code></pre>
  <hr />
  <p>I got this reponse back</p>
  <pre><code>&lt; Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&amp;state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7
  </code></pre>
  <p><strong>Note</strong> : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7</p>
  <hr />
  <h1>PHP</h1>
  <p><strong>Note</strong> : state = b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7</p>
  <pre><code>$cmd = 'curl -c session_cookies.txt &quot;https://login.uat.site.be/openid/oauth/authorize?client_id=site&amp;state=b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7&amp;nonce5ba13e5f-256d-425d-808b-1e05d2aa3d72&amp;response_type=code&amp;claims=%7B%22id_token%22%3A%7B%22http%3A%2F%2Fsite.be%2Fclaims%2Froles%22%3Anull%7D%7D&quot; 2&gt;/dev/null| curl -v -b session_cookies.txt -L -H &quot;Content-Type: application/x-www-form-urlencoded&quot; -v -d 'j_username=manager-sitelogin@gmail.com&amp;j_password=site1' &quot;https://login.uat.site.be/openid/login.do&quot; 2&gt;&amp;1 &gt;/dev/null | grep Location | grep code=';
  
  
  $result = shell_exec($cmd);
  
  dd($result); 
  </code></pre>
  <hr />
  <blockquote>
  <p><strong>Note</strong> : state != b4cf8fe7-aa68-4b25-8f9a-03a67fb420c7</p>
  <p><strong>Note</strong> : state = 12345678-256d-425d-808b-1e05d2aa3d72</p>
  </blockquote>
  <pre><code>&lt; Location: https://testserver.sitenets.com/user/secure/dashboard?code=zvk495dsnq1ycLKZgN8oqfFxQogg2oql&amp;state=12345678-256d-425d-808b-1e05d2aa3d72
  </code></pre>
  <p>When I run <code>shell_exec($cmd)</code>, my state always come back different the one that I submitted. How is this possible?</p>
  <p>Is it caching somewhere on my local machine? Should I clear something?</p>
  <p>Why <code>shell_exec()</code> return slightly different result than if I would have do it directly on Terminal? I even tried using <code>exec()</code>, same result.</p>