title: Symfony: authenticate with API KEY doesn't keep sessions
body: <p>As Symfony Manual I followed this steps <a href="http://symfony.com/doc/current/cookbook/security/api_key_authentication.html" rel="nofollow">http://symfony.com/doc/current/cookbook/security/api_key_authentication.html</a> to enable the authentication via an external token provided in the URL.</p>
  
  <p>When I pass the token in the URL Symfony do the login but if I change page I lose the session.</p>
  
  <p>This is the code:</p>
  
  <pre><code>public function createToken(Request $request, $providerKey)
  {
  
      $targetUrl = '/myproject/login';
      if (!$this-&gt;httpUtils-&gt;checkRequestPath($request, $targetUrl)) {
          // DO REDIRECT
      }
  
      if (!$request-&gt;query-&gt;has('apikey')) {
          throw new BadCredentialsException('No API key found');
      }
  
      return new PreAuthenticatedToken(
          'anon.',
          $request-&gt;query-&gt;get('apikey'),
          $providerKey
      );
  }
  </code></pre>
  
  <p>Thanks</p>