We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Transfer of 'external' $_SESSION to phalcon

Hi, If we try to integrate phalcon with a standalone library\script which uses its own native $_SESSION what is the best way to transfer the $_SESSION to the Phalcon environment.

We can get this working like below but we think this is probably not a good method to do a session_start()

$session_start();
$di->setShared('session', function() {
    $session = new Phalcon\Session\Adapter\Files();
    $session->start();
    $session->set('test', $_SESSION);
    return $session;
});


98.9k
Accepted
answer

You don't need to do this, accessing $session->get('test') is like doing $_SESSION['test']



2.6k

So simple I didn't see it. Thank you.