incomplete Phalcon\Session\AdapterInterface
Hi,
as I can see https://github.com/phalcon/cphalcon/blob/master/phalcon/session/adapterinterface.zep#L27
there is not a method called setId() i.e. session user will be tied to PHPSESSID (in case of using cookies) or need to call native php function to set new ID.
Or is it intentionally? if so why?
Thanks
UPD. yet another possible improvement can include a few extra methods:
public function bind($key, &$value);
and
// removes session variable right after retrieval
public function getOnce($key, $default = NULL);
@Studentsov
well, what is wrong if I want to use cookie name iam instead of PHPSESSID? (for now I am considering only cookie based sessions bootstraps).
How do I achieve that if I did receive an instance of Phalcon\Session\AdapterInterface from DI container, like this
$di->setShared('session', function() {
return new \Phalcon\Session\AdapterInterface {
// ...
};
});
There is not such method as setID, thus I need to use some other means. Is it safely to rely that we use standard sessions of PHP and use session_id('iam')? Of course nope, eg. see an example of PHP independent session here https://github.com/kohana/core/blob/3.3/master/classes/Kohana/Session.php
so what I am expected to do then?
I at first misunderstood your question. However, the method is defined in an abstract class: https://github.com/phalcon/cphalcon/blob/2.1.x/phalcon/session/adapter.zep#L225
@Studentsov You got a point. It is exactly what I do mean.
abstract class Adapter implements AdapterInterface {
// ...
public function setId(...)
{
// ...
}
}
We need to make software in terms of interfaces, to decouple as much as possible from an implementations
IMHO. abstract class need not to use $_SESSION at all. Look at Views rendering engines approach... There is PHP engine which simply uses standard PHP, and there is Volt. We can use that we want... The same approach is well suited to abstract session adapter, just use some internal container for data, then concrete PHP session adapter can just bind $_SESSION to that container and voila!
And we still can have non PHP based concrete session adapters by going this way
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues