Getting Session Variable from within AppKernel.php in Symfony
<p>Fairly new to PHP and Symfony: How do I gain access various session variable from within an include file that is included in AppKernel.php?  I'm using Symfony 2.8. I've successfully tested the following, but it's not officially approved. I'd prefer to use Symfony objects to access the session. </p>

<pre><code>session_start();
if (isset($session['userid'])) {
    $userid = $_SESSION['_sf2_attributes']['userid'];
}
</code></pre>

<p>I tried getting the session from the Symfony Request object using the following, but it looks like "Request::createFromGlobals" is creating another Request object vs. creating a Request object from an existing Request object.</p>

<pre><code>use Symfony\Component\HttpFoundation\Request;

require_once '/var/www/html/vendor/autoload.php';

...

$request = Request::createFromGlobals();
$session = $request-&gt;get('session');
</code></pre>

<p>The $session variable returns null.</p>