Phalcon session to handle both normal session and SESSID in http header
We are developing a system that both serves as regular web platform and also serves an API for Sencha based iOS/Android App’s.
For this we need to modify Phalcon's regular session service, if anyone has an idea to do this ?
Our session implementation in the DI:
use Phalcon\Session\Adapter\Redis as RedisSession;
$di->setShared('session',function() use ($di) {
$session = new RedisSession([
'uniqueId' => '',
'host' => '',
'port' => '',
'persistent' => '',
'lifetime' => '',
'prefix' => '',
]);
$session->start();
return $session;
});
The standard session gets the Session ID from the cookie via the http header, like the usual http response headers from a browser:
Host: somesite.com
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Cookie: PHPSESSID=c1755e44a3f3265e1ec6f0d01dc10177
But the Sencha App will not send the session ID in a cookie, but directly in the http headers, as 2 extra fields, where device-token holds the session ID:
device-id:
device-token: c1755e44a3f3265e1ec6f0d01dc10177
So the big queston is:
How do we get Phalcon to accept both normal PHP Session id like from:
$headers = getallheaders();
$headers['Cookie’];
… and if it is not found there, then get the session ID from:
$headers['device-token’];
Anyone has an idea ?