2
<?php
session_start();
var_dump($_SESSION);
?>

I tried the above code in root of the magento system but it fails to list all the session variables. It returns null.

Then how the magento stores all the session values?

Does it use $_SESSION super global or it follows some other way to store session?

2 Answers 2

1

Magento uses its own models to handle sessions such as:

  • Mage_Core_Model_Session
  • Mage_Customer_Model_Session
  • Mage_Checkout_Model_Session

The low level class that handles the session_start is Mage_Core_Model_Session_Abstract_Varien

Native Magento handles automatically the session start thus you shouldn't have to call session_start in your code

0
1

You can use magento session outside of magento such as

          <?php

           echo getcwd();

           define('MAGENTO_ROOT', getcwd()); 

           $mageFilename = MAGENTO_ROOT . '/app/Mage.php';

           require_once $mageFilename;

           Mage::app()->loadArea('frontend');

           // access the magento session outside


                 $customerSession = Mage::getModel('customer/session');

                 print_r($customerSession);

                 $_product = Mage::getModel('catalog/product')->load(1);
                echo $_product->getName();
             ?>

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.