0

I'm working on a module with a custom namespace session. I extended the Session class and created a new object, but every time I use the new object it overwrites the parent one while I need 2 different instances

Can a custom session be instantiated twice ? thanks

1 Answer 1

0

Ok, I found it, the extended class should override the parent method __construct and use a different namespace

 public function __construct()
    {
        $namespace = 'different_name_from_parent';
        $this->init($namespace);
        Mage::dispatchEvent('event_name', array('session_name'=>$this));
    }

Otherwise Mage_Core_Model_Session_Abstract_Varien::init() will merge the data array from the parent session

$this->_data = &$_SESSION[$namespace];

and the result is a copy of the same object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.