<p dir="auto">When doing functional testing using the test client (Symfony\Bundle\FrameworkBundle\Client) and disabling kernel reboots between requests using <code class="notranslate">$client-&gt;disableReboot()</code>, upon the 2nd request I'm running into this:</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/symfony/symfony/blob/7617492914bb21672003fc7d30511bc0da9693ad/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php#L134">symfony/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 134
      in
      <a data-pjax="true" class="commit-tease-sha" href="/symfony/symfony/commit/7617492914bb21672003fc7d30511bc0da9693ad">7617492</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L134" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="134"></td>
          <td id="LC134" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">throw</span> <span class="pl-k">new</span> \<span class="pl-v">LogicException</span>(<span class="pl-s">'Cannot set session ID after the session has started.'</span>); </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">I don't have a test case right now, but you should be able to reproduce this easily.</p>
<p dir="auto">Hi there,</p>
<p dir="auto">the exception is thrown by this line:<br>
<a href="https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php#L134">https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php#L134</a></p>
<p dir="auto">My setup works completely fine within a valid PHP environment (without <code class="notranslate">TestSessionListener</code>) - data getting stored in the session before the <code class="notranslate">TestSessionListener::onKernelRequest</code> has been executed (using <code class="notranslate">MockFileSessionStorage</code>).</p>
<p dir="auto">What's the intention of this exception? I can't get my head around it. The <code class="notranslate">TestSessionListener</code> is explicitly doing this (<code class="notranslate">setId</code>) and if there is another object accessing the session before the <code class="notranslate">TestSessionListener</code> sets the id, an id is automatically generated. The listener is not correctly mimicking the session creation of PHP and this exception makes it (for some parts) unusable.</p>
<p dir="auto">If there is no actual use on this exception, it may be removed, no?</p>