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

session stored in cookies

Hi,

Is there an already built session being persisted in cookies?

I'd like to use following API on backend:

$controller->session->set(array('user_id' => 1));

$controller->session->get('user_id');

# => 1

Thanks.

save session backend in cookie?, its no recommended,

try with other adapter: example: Redis: in your services:

    $di->setShared('session', function() {
    $session = new Phalcon\Session\Adapter\Redis(array(
        'path' => "tcp://127.0.0.1:6379?weight=1",
        'name' => SITE_DOMAIN . '-'
    ));

    $session->start();

    return $session;
});

in your controller:

$this->session->set('SESSION_USER_ID', $o_user->getIduser());
if ($this->session->has('SESSION_USER_ID')){}
$this->session->get('SESSION_USER_ID');

;)