$session->start(); clears existing Memcache key

Hi! I use this code generated by Phalcon Developer Tools

use Phalcon\Session\Adapter\Memcache as SessionAdapter;

$di->set('session', function () {

    $session = new SessionAdapter(array(
        'host' => '',
        'port' => 11211,
        'lifetime' => 8600,
        'prefix' => 'memc.sess.',
        'persistent' => false


    return $session;

I have existing Memcache key and $_COOKIE['PHPSESSID'].

$session->start(); create session with sid = $_COOKIE['PHPSESSID'] but clears all existing data in Memcache key.

How can i fix it?


Currently $session->start() does not reset any cookies, what version of Phalcon are you using?

edited Sep '14

No, all right with my cookie. I use 1.3.2

$session->start() get sid from cookie, so in Memcache session data is in 'memc.sess.'.$_COOKIE['PHPSESSID'] key and it's cool.

But this key has already data, for example 'user_id', because I logged in another subdomain, which does not use phalcon.

And $session->start() clear all data in 'memc.sess.'.$_COOKIE['PHPSESSID'] Memcache key.

edited Sep '14

I think, you may want to check this function: http://php.net/manual/en/function.session-set-cookie-params.php, this will allow you to set the cookie on every subdomain

session_set_cookie_params(0, '/', '.some_domain.com');
edited Sep '14

I'm sorry, you did not understand me. My cookie is allowed.

I logged in another subdomain and save my session into Memcache with key


Then I go to the subdomain with phalcon. Phalcon "see" my cookie with sid and it runs session with the same sid. It's fine for me.


Before $session->start()




but after $session->start() it's return empty string, because $session->start() remove all data in my Memcache key.

This is my problem...