2 Replies Latest reply on Jul 1, 2013 2:17 PM by rush_pawan

    Session Store

    krishna516 Level 1


           I am trying for sessions store in client context. In day.com they just gave pieces of code how to do it, but I didnt get anything. Please help me how to have session store in client Context.


      Thanks in Advance,

      Krishna Reddy.

        • 1. Re: Session Store
          Yogesh Upadhyay Level 4

          May be something like this to create store


          var storeName = "my-store";

              var store = CQ_Analytics.StoreRegistry.getStore(storeName);

              if ( !store ) {

                   store = CQ_Analytics.PersistedJSONStore.registerNewInstance(storeName, {"test1":"", "test2":"test3"});


              store.setProperty("test1", "test");

             store.setProperty("test2", "blahblah");


          More info [1] http://dev.day.com/docs/en/cq/current/developing/client_context_detail.html#Creating a Listener to react to a Session Store Update

          [2] http://dev.day.com/docs/en/cq/5-5/widgets-api/index.html



          • 2. Re: Session Store
            rush_pawan Level 4

            Hi Krishna,


            Adding new stores in client context is different between 5.4 and 5.5 & upper version.


            In 5.4


            1. It manages all the stores under clickstreamcloud library. so if you access \libs\cq\personalization\clientlib\source\clickstreamcloud you will see all different types of stores with different configuration

            2. Now the best way to create custom stores is to copy/paste any one of them and modify as per need. For example sitedata store is used to store site information.

                 a. First give a unique name to your store maager say CustomPropMgr and use same name accross everywhere in the store

                 b. if you want to create custom store with permanent storage then use below

                      CQ_Analytics.CustomPropMgr .prototype = new CQ_Analytics.PersistedSessionStore(); 

                      // instead of only session store new CQ_Analytics.SessionStore()

                 c. assign the property name against which you want to store the property and lookup name for your store

                 d. now at bottom if you go under the method "addListener" you have to register your store manager here including all others, dont forget to add sitemgr in this case as you copy/pasted it as below

            reg.call(this, CQ_Analytics.SiteDataMgr);

            reg.call(this, CQ_Analytics.CustomPropMgr );


            this way you can add a new custom store in client context.


            Now in 5.5 and upper version


            1. It changes the structure of client context management. Now we have a separate component structure for each store. So if you access /libs/cq/personalization/components/contextstores you will see each store as component and when you access their clientlib folder for example for store /libs/cq/personalization/components/contextstores/profiledata. Still we are having other store managed from old location /libs/cq/personalization/clientlib/source/clickstreamcloud you can refer that too

            2. Now apart from configuring the store js file as mentioned in 5.4 steps you have extra step is to create a custom component as per your need, define list of properties and use those properties in your store js file via externalizer

                 CQ_Analytics.ProfileDataMgr.prototype.LOADER_PATH = CQ_Analytics.Utils.externalize("/libs/cq/personalization/components/profileloader/content /load.js", true);


            and then



            which loads these properties authored earlier


            You have to go more in details and ones you figure out one, it will be easy to create your customize/add new.


            Let me know if you need more information.