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

Securing session cookie

How do I enable setSecure and useEncryption on the session cookie used by Phalcon\Session. I'm using the memcache apapter.

Thanks.



85.5k

$this->di->set('cookies', function(){

            $cookies = new \Phalcon\Http\Response\Cookies();

            return $cookies;
        });

        $this->di->set('crypt', function () {
            $crypt = new \Phalcon\Crypt();

            $crypt->setKey('#1dj8$=dp?.ak//j1V$'); // Use your own key!

            return $crypt;
        }, true);

https://docs.phalcon.io/en/latest/reference/cookies.html