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

phalcon cookies

<?php

class SessionController extends Phalcon\Mvc\Controller
{
    public function loginAction()
    {
        //检测cookie之前有没被设置过
        if ($this->cookies->has('remember-me')) {

            //获取cookie
            $rememberMe = $this->cookies->get('remember-me');

            //获取cookie的值
            $value = $rememberMe->getValue();

        }
    }

    public function startAction()
    {
        $this->cookies->set('remember-me', 'some value', time() + 15 * 86400);
    }
}

这个例子设置cookie和获取cookie都不行啊

In your loginAction all I can see is that you're getting the cookie. That means you have to first call startAction to set your cookie.

I see you're following https://docs.phalcon.io/en/latest/reference/cookies.html

I have to warn you that is just an example and not secure enough for persistent sessions.



27.0k

有问题可以加我发我邮箱[email protected]或者qq 525695314



2.8k

$this->cookies->send();