title: Cookie Corruption
body: <p>I have a weird issue with a php redirect script that does the following:</p>
  
  <ol>
  <li>Plant a cookie in the user's browser, or read the existing cookie if there is one.</li>
  <li>Redirect the user to another url (the URL for redirect is a parameter in the original URL, e.g. <code>http://my.redir.com?url=www.google.com</code>).</li>
  <li><strong>Log the redirect</strong> (time, user-agent, referrer, cookie).</li>
  </ol>
  
  <p>Every once in a while (very rare, one in millions), I see a cookie that got corrupted in the log file.
  All cookies have the format <code>XXXX-XXXX</code>, when the Xs are a-f or 0-9 (so a valid cookie can be <code>7bfab3-d8694</code>). The corrupted cookies have the characters <code>:</code> or <code>/</code> replacing one of the characters or hyphens, e.g. <code>7bfa:3-d8694</code> or <code>7bfab3/d8694</code>.</p>
  
  <p><strong>The question is</strong>, what can cause this? 
  Can it be a problem with my script or the server it is running on, or is it more likely to be a problem in the user's browser?</p>
  
  <p>-- more info --</p>
  
  <p>The corrupted cookies I have found had the user-agents:</p>
  
  <pre><code>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Sky Broadband; GTB7.1; Sky Broadband; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Sky Broadband)
  Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_4_11; en) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/4.1.3 Safari/533.19.4
  </code></pre>