I'm not able to reproduce this, I have used these scenarios, all of them are working:
1) Cookies without session without encryption:
<?php
$di = new \Phalcon\DI\FactoryDefault();
$di['cookies'] = function() {
$cookies = new Phalcon\Http\Response\Cookies();
$cookies->useEncryption(false);
return $cookies;
};
class X extends \Phalcon\DI\Injectable
{
public function x()
{
$cookies = $this->getDI()->getCookies();
$cookies->set("mycookie", "test", time() + 3600, "/");
}
}
$x = new X;
$x->setDI($di);
$x->x();
$di['cookies']->send();
var_dump($_COOKIE);
Running here: https://phosphorum.com/test2.php
2) Cookies with session without encryption:
<?php
$di = new \Phalcon\DI\FactoryDefault();
$di['session'] = function() {
$session = new \Phalcon\Session\Adapter\Files();
$session->start();
return $session;
};
$di['cookies'] = function() {
$cookies = new Phalcon\Http\Response\Cookies();
$cookies->useEncryption(false);
return $cookies;
};
class X extends \Phalcon\DI\Injectable
{
public function x()
{
$cookies = $this->getDI()->getCookies();
$cookies->set("mycookie", "test", time() + 3600, "/");
}
}
$x = new X;
$x->setDI($di);
$x->x();
$di['cookies']->send();
var_dump($_SESSION);
var_dump($_COOKIE);
Running here: https://phosphorum.com/test3.php
2) Cookies with session with encryption:
<?php
$di = new \Phalcon\DI\FactoryDefault();
$di['session'] = function() {
$session = new \Phalcon\Session\Adapter\Files();
$session->start();
return $session;
};
$di['cookies'] = function() {
$cookies = new Phalcon\Http\Response\Cookies();
return $cookies;
};
$di['crypt'] = function() {
$crypt = new Phalcon\Crypt();
$crypt->setKey('.1dj8$=dp?.ak//j1V$');
return $crypt;
};
class X extends \Phalcon\DI\Injectable
{
public function x()
{
$cookies = $this->getDI()->getCookies();
$cookies->set("mycookie", "test", time() + 3600, "/");
}
}
$x = new X;
$x->setDI($di);
$x->x();
$di['cookies']->send();
var_dump($_SESSION);
var_dump($_COOKIE);
Running here: https://phosphorum.com/test4.php
You may need to close and reopen the browser to see them running independtly.
Could you please post a full test that reproduce the problem?