1

I came accross a line Mage::app()->cleanAllSessions(); and going through the function I saw that it fetches the session save path and deletes it. i havent specified any session_save_path in my local.xml and have all my sessions saving in files, when i run this code it doesnt really clears the var/session folder, so what does it do actually?

FYI, calling session_save_path() returns c:\xampp\tmp.

0

Basically, session_save_path returns the path of the current directory used to save session data. We can set the path for it, ex: session_save_path('var/session'). If we didn't set any path value, the session data will store in the tmp folder of our web service. This is reason why when calling session_save_path(), it returns c:\xampp\tmp in your case.

Look into this file:

downloader/Maged/Controller.php

protected function cleanCache()
{
    ......     
    Mage::app()->cleanAllSessions();
    ......             

}

As we can see,Mage::app()->cleanAllSessions() is used for updating process. And, we don't set any value for session_save_path in this process, so, the tmp folder will store the session data. After updating successfully, we need to clear these values.

Now, we should find the session path of our Magento website.

Navigate to the core model session files:

app/code/core/Mage/Core/Model/Session/Abstract.php

public function getSessionSavePath()
{
        if (Mage::isInstalled() && $sessionSavePath = Mage::getConfig()->getNode(self::XML_NODE_SESSION_SAVE_PATH)) {
            return $sessionSavePath;
        }
        return parent::getSessionSavePath();
}

app/code/core/Mage/Core/Model/Session/Abstract/Varien.php

public function getSessionSavePath()
{
    return Mage::getBaseDir('session');
}

The session save path will be set if we have set this value in app/etc/local.xml. If not, it gets the path from Mage::getBaseDir('session') -> var/session will be used.

Try with an example:

app/etc/local.xml

<global>
    ......
    <session_save_path><![CDATA[var/store_session]]></session_save_path>
    ......
</global>

Print out the value:

app/code/core/Mage/Core/Model/Session/Abstract.php

public function getSessionSavePath()
{
        if (Mage::isInstalled() && $sessionSavePath = Mage::getConfig()->getNode(self::XML_NODE_SESSION_SAVE_PATH)) {
            var_dump($sessionSavePath);
            die;
            return $sessionSavePath;
        }
        return parent::getSessionSavePath();
}

object(Mage_Core_Model_Config_Element)#26 (1) { [0]=> string(17) "var/store_session" }

  • Thanks for your reply. You initially said that if we dont have the session_save_path value et then it uses tmp folder of the webservice and then later again you have menioned that it uses var/session folder. I am a bit confused here. Also what session value does it save on updating a process like clearning cache for that matter. I monitored the tmp as well var/session folder, cleanAllSessions() doesnt seem to clean anything. – Twinkal Sep 11 '16 at 15:06
  • cleanAllSessions() -> is used for the updating process. The normal session of our Magento site will be stored under var/session folder as default. Look into the core session Magento, Magento will check and get the session path from app/etc/local.xml config. If not, it gets the path from Mage::getBaseDir('session') ->var/session will be used. – Khoa TruongDinh Sep 11 '16 at 15:15
  • You should create var/store_session and declare it in app/etc/local.xml: <session_save_path><![CDATA[var/store_session]]></session_sa‌​ve_path>. You will see what happens. – Khoa TruongDinh Sep 12 '16 at 12:45
  • Your answers are contradictory..is session_save_path and getSessionSavePath the same thing? – Twinkal Sep 26 '16 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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