title: Why does Twitter webview clear my session cookies?
body: <p>I'm creating your standard login in PHP. It relies on the user's session remaining the same to keep the user logged in. The session has been persisting as expected on desktop browsers, Safari on iOS, and webview in Facebook iOS app. However, it is not persisting on webview in Twitter iOS app.</p>
  <p>I have this <a href="http://toadgate.mooo.com/" rel="nofollow noreferrer">simple page</a> to print out the session:</p>
  <pre><code>&lt;?php
          session_start();
  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h1&gt;$_SESSION&lt;/h1&gt;
  &lt;?php
          print_r($_SESSION);
  ?&gt;
  &lt;h1&gt;$_COOKIE&lt;/h1&gt;
  &lt;?php
          print_R($_COOKIE);
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <hr />
  <h1>Safari on iOS</h1>
  <ol>
  <li>Open the page in Safari on iOS.</li>
  <li>Reload the page 10 times.</li>
  <li>The same session ID is printed every time.</li>
  </ol>
  <p><img src="https://i.stack.imgur.com/gOr7Lm.png" alt="enter image description here" /></p>
  <hr />
  <h1>Facebook on iOS</h1>
  <ol>
  <li>Post the link to your Facebook wall.</li>
  <li>Tap the link 10 times.</li>
  <li>The same session ID is printed every time.</li>
  </ol>
  <p><img src="https://i.stack.imgur.com/0hb2Bm.png" alt="enter image description here" /><img src="https://i.stack.imgur.com/UZNHKm.png" alt="enter image description here" /></p>
  <hr />
  <h1>Twitter on iOS</h1>
  <ol>
  <li>Tweet the link on Twitter.</li>
  <li>Tap the link 10 times.</li>
  <li>The <strong>session ID is missing</strong> every time.</li>
  </ol>
  <p><img src="https://i.stack.imgur.com/f3727m.png" alt="enter image description here" /><img src="https://i.stack.imgur.com/dKcCDm.png" alt="enter image description here" /></p>
  <hr />
  <p>The only major difference between Twitter and everyone else is that Twitter converts all links with their shortening service. If you inspect the website source code of your posts, you'll see:</p>
  <pre><code>&lt;a href=&quot;t.co/someCode&quot;&gt;yourOriginalLink.com&lt;/a&gt;
  </code></pre>
  <p>This affects your referrer. But how exactly would the referer screw up your session?</p>
  <p>I know other websites have gotten sessions to persist on Twitter because I've logged in on those other apps and I remain logged in every time I launch their site. You can look at Meerkat for example. Just search for #meerkat in your Twitter iOS app and click on the link in any of the tweets. You'll be asked to log in. If you click on a second Meerkat link, it will remember that you've already logged in before.</p>