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.
session_start();
if (isset($session['userid'])) {
$userid = $_SESSION['_sf2_attributes']['userid'];
}
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.
use Symfony\Component\HttpFoundation\Request;
require_once '/var/www/html/vendor/autoload.php';
...
$request = Request::createFromGlobals();
$session = $request->get('session');
The $session variable returns null.
include foo.php';So the heavy lifting is happening in foo.php.