Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Create your own session namespace for storing your custom session variable
Jr. Member
Total Posts:  28
Joined:  2012-05-16

First, make sure you have your own custom module if not then create.

and make session.php file in model folder of your module and write down below code in it.

class <namespace>_<module>_Model_Session extends Mage_Core_Model_Session_Abstract 
public function __construct() {
Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));

and then now you can store session variable like

// Set the "foo" variable
// Same thing

// Another example. Let's say we want to name our variable "foo_bar"
// or

// Get data the same way
// or

you can see output if you print array

[Mysession] => Array
[_session_validator_data] => Array
[remote_addr] =>
[http_x_forwarded_for] => 
[http_user_agent] => Mozilla/5.0 (X11UbuntuLinux i686rv:17.0Gecko/17.0 Firefox/17.0

[session_hosts] => Array
[] => 1

[foo] => bar

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top