I'm upgrading a product from Phalcon 3.4.5 to 4.0. In 3.4.5, I create a session and set some session variable, such as the user's name and email address. I am then able to acess the session variables in my volt files like:
{% if session is defined and session.get('user').id is defined %}
{% set support_full_name = session.get('user').first_name ~ ' ' ~ session.get('user').first_name %}
{% set support_email = session.get('user').email %}
{% endif %}
After updating to Phalcon 4.0 I am unable to access the session variables in my volt files. "session" is not defined at all.
I'm creating the session in index.php using this code:
$di->set('session', function() use ($di) {
$session = new Phalcon\Session\Manager();
$files = new Phalcon\Session\Adapter\Stream();
$session->setAdapter($files)->start();
return $session;
});
And I'm setting the session data using:
$session->set('user', (object) array(
'id' => $user->id,
'email' => $user->email,
'first_name' => $user->first_name,
'last_name' => $user->last_name,
));
I have verified that the session data is created and data is set. I can access the session data in my PHP files and I've dumped the data and it is set.
I've searched and can't find anything obvious, so I assume I'm suffering from "Excessive Bark up My Nose Syndrome". I'm hoping someone can help me see what I can't see.
Am I missing something that I have to do in 4.0 to make the session data accessible to Volt?