Search code examples
phpsessionmagentomagento-1.9

How to maintain custom session for custom login and registration account module in magento 1.9.2 community edition


I am developing a module in which I am creating separate account which not using anything of customer. I am not able to create a separate session for my module. I tried to study customer module's session.php but I didn't get it. I am not understanding this code:

public function __construct()
{
    $namespace = 'customer'; 
}

Please guide me on how I can achieve it.


Solution

  • Regarding customer namespace, I assume you are discovering app/code/core/Mage/Customer/Model/Session.phpFile.

    This is basically the namespace of your model, it holds for usage it like Mage::getModel('customer/session').

    So if your module named yourCompany_yourModel , you registered your yourCompany_yourModel model prefix in config.xml and created constructor as above in app/code/local/yourCompany/yourModel/Model/Session.php

    if you make

        public function __construct()
        {
            $namespace = 'yourModule'; 
            $this->init($namespace);
        }
    

    then you can use it in your code like:

    Mage::getSingleton('yourModule/session')->setYourVariable($yourVar);