So I've got the default Phalcon setup, with my services.php file looking like this:
use Phalcon\Session\Adapter\Files as SessionAdapter;
// ... Other Services Code here
$di->setShared('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
And my controller looks like this:
<?php
use Phalcon\Mvc\Controller;
class AdminController extends Controller
{
public function indexAction()
{
if ($this->request->isPost() && $this->request->getPost("password") === "thePassword")
{
$this->session->set("adminLogin", true);
}
if($this->session->has("adminLogin") && $this->session->get("adminLogin"))
{
$this->view->pick("admin/admin");
}
else
{
$this->view->pick("admin/login");
}
}
}
For a very basic, password-protected admin screen. However, it always kicks me back to the login page, even if the password is correct.
I've tried just putting in this:
$this->session->set("adminLogin", true);
var_dump( $this->session );
And I get this as output:
object(Phalcon\Session\Adapter\Files)#33 (3) { ["_uniqueId":protected]=> NULL ["_started":protected]=> bool(false) ["_options":protected]=> NULL }
I tested just setting a variable inside the password checking block and then checking for that variable on the admin view block, and that works, so the problem is with my sessions.