I have been wondering always, where is all the registry data stored in Magento ?

I know that even singleton objects are stored in the registry. And registry is just a static array variable of the Mage class.

I have a couple of questions here to clear my confusion:

  1. Is registry different for different users ? I mean is it created on a per-user (per HTTP request) basis?

For example,

Mage::register('foo', 'Hello World'); //set a value for foo
Mage::registry('foo'); //will this return hello world for all HTTP users ?
  1. Is registry data stored in sessions ? If not how will Magento identify which user invoked the registry data ?

I have read Alan Storm's blog article as well as his answer on StackOverFlow regarding this. But I couldn't kill the confusion. Please correct me If I you think my basics are messed up. Thanks


4 Answers 4


The registry stores data to memory which is specific to that request (rather than user or anything else), and persists for the duration of that request only. The principle is very simple really, the Mage class is instantiated as a singleton object for every request and the instantiated Mage object remains in memory, and is accessible in all classes (and templates) until the request completes and the response is sent.

As the object is a singleton, whenever you access it you get the same object. All that is happening is that you are storing values to this object, so when one class stores a value, and another accesses it they are both working on the same object and the second class is able to retrieve the value the first class set.

  • 2
    So its alive only for ONE request ? Meaning if I load a page in Magento, one request is DONE and registry data is flushed ?
    – Hashid
    Nov 17, 2014 at 11:08
  • 5
    Yes values you set with Mage::register() persist for that request only. If you want to store user specific data you should use the session, the registry is really just designed to make data portable between classes. Nov 17, 2014 at 11:13
  • 1
    that makes sense! Same applies to singleton instance as well ?
    – Hashid
    Nov 17, 2014 at 11:17
  • 1
    Yes exactly the same - if you look at the getSingleton() method of the Mage class it actually stores the data to the registry. Nov 17, 2014 at 11:21

The registry is stored in memory and is per HTTP request, so you are not able to share data between different requests or users.

  • But how will Magento map the HTTP Request and registry ?
    – Hashid
    Nov 17, 2014 at 11:03

Magento Registry stored in the application’s memory.

when ever your script is done running, whatever you had stored in the registry is gone, so there is no need to worry about clearing it out (unless the script you are running is storing large objects in the registry and is looping through a lot of data).

In such case, you have to unregister your entries when you are done with them.

the Registry is just a static property of the Mage class. see for details

but still I couldn’t really find out a good explanation

2) for each users there will be separate registry per request on server.

hope this will make little clear in your mind


In Magento 2 you can implement registry. I have given live example in my tutorial video you can see.


If you have any confusion regarding registry pattern you can reply me. I assure you i will solve your confusion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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