Create your own session namespace for storing your custom session variable

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() {

$namespace = 'mysession';

Mage::dispatchEvent('myapp_session_init', array('myapp_session' => $this));

and then now you can store session variable like
// Set the "foo" variable
// Same thing
Mage::getSingleton("myapp/session")->setData("foo", "bar");// Another example. Let's say we want to name our variable "foo_bar"
// or
Mage::getSingleton("myapp/session")->setData("foo_bar", "bar");

// Get data the same way
// or
you can see output if you print array
 [Mysession] => Array
[_session_validator_data] => Array
[remote_addr] =>
[http_via] =>
[http_x_forwarded_for] =>
[http_user_agent] => Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:17.0) Gecko/17.0 Firefox/17.0
)[session_hosts] => Array
[] => 1

[foo] => bar


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s