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

D/Encryption cookies problem

I set the cookie looks like this is my service

 $di->set('cookies', function() {
            $cookies = new Phalcon\Http\Response\Cookies();

            return $cookies;
        });

And by the way the method $cookies->setEncryption(false); specified in this documentation https://docs.phalcon.io/en/latest/reference/cookies.html#encryption-decryption-of-cookies does not work

I'm trying to (at the time of authorization) to get username of cookies, doing so

$username = $this->cookies->get('username'); $username_v = $username->getValue();

$username_v var_dump show string(32) "admin" that is not (5)

For this reason I can not get the data from the database using a login from cookies, help solve the problem

Покажи больше кода, и момент записи в куку и момент поиска по значению.

edited Apr '14

Got the same issue. Getting values doesn't work properly if using the encryption. var_dump of $this->cookies->get('username')->getValue() prints this:

string 'U1fI4UY3_mstXCmU61��������������' (length=32)

To clarify: the username is "U1fI4UY3_mstXCmU61" and I'm using v1.3.1.

This https://github.com/phalcon/cphalcon/issues/1150 helps, but I can't wrap every getValue() in rtrim().



8.1k

Just add


$crypt->setMode(MCRYPT_MODE_CFB);

to crypt service