Hi can you please tell me the syntax of calling these functions. I tried to
do the following.

var $cookieName = "arrCookie" //Assuming this is the cookie name

where the value of the cookie is been set like in my case value should be
array of objects?????.

1>> how to set value of this cookie ?
I copied all the functions given by you 
    sterilizeQueryString = function(input,splitter,pair){
      try{
          if(typeof input != 'string') return null;
          if(!splitter){
              splitter = "&";
          }
          if(!pair) pair ="=";
          var a = input.split(splitter), b = Array();
          for(var i=0; i < a.length; i++)    a[i] = a[i].split(pair);
 
          for(var i = 0; i < a.length; i++) b[a[i][0]] = a[i][1];
 
          return b;
      }
      catch(e){
          $.iLogger.log(e.name + ': ' + e.message,
'error','sterilizeQueryString();');
      };
  };
 
  objectToQueryString = function( a , joiner, pair) {
      try{
          var s = [];
          if(!pair) pair ="=";
          if((typeof a == "object")){
              for(var j in a){
                  if(typeof a[j] == "object" && a[j]){
                      s.push(encodeURIComponent(j) + pair + "__"
+objectToQueryString(a[j],"**","##") +"__");
                  }
                  else{
                      s.push( encodeURIComponent(j) + pair
+encodeURIComponent( a[j] ) );
                  }
              };
              return s.join(joiner);
          }
          else{
              return a;
          };
      }
      catch(e){
          $.iLogger.log(e.name + ': ' + e.message,
'error','objectToQueryString();');
      };
  };
 
  queryStringToObject = function(s){
     try{
         if(s && typeof s == "string"){
             s = sterilizeQueryString(s);
             for(var j in s){
                 if(/__(.*)__/.test(s[j])){
                    s[j] = s[j].replace(/__/g,"");
                     s[j] = sterilizeQueryString(s[j],"**","##")
                 };
             };
            return s;
        }
        else{
             return s;
         };
     }
     catch(e){
         $.iLogger.log(e.name + ': ' + e.message,
'error','queryStringToObject();');
     };
 } 
/**
> >  * @name getSetCookies
> >  * @example getSetCookies();
> >  * @param {Boolean} getOnly
> >  * @desc Purpose of this function is to set and get cookie data
> >  * @see objectToQueryString
> >  * @see queryStringToObject
> >  */
> > getSetCookies = function(getOnly){
> >     $.iLogger.log('getSetCookies();');
> >     try{
> >         //
> >         if(getOnly){
> >             var tempSiteData = $.cookie($cookieName);
> >             if(tempSiteData){
> >                 $sitedata = queryStringToObject(tempSiteData);
> >             }
> >             else{
> >                 $.cookie($cookieName,
> objectToQueryString($sitedata,"&"),
> > $cookieParams);
> >             }
> >         }
> >         else{
> >             $.cookie($cookieName, objectToQueryString($sitedata,"&"),
> > $cookieParams);
> >         };
> >     }
> >     catch(e){
> >         $.iLogger.log(e.name + ': ' + e.message, 'error',
> > 'getSetCookies();');
> >     };
> > }; // end : getSetCookies 

I've doubt like do I need to use only getSetCookies function to get and set
the object of array from cookie. or

As of my assumption  getSetCookies(false) should be used to set the value of
cookie to query string.
and getSetCookies(true) should bring back the array of object.

I think I'm missing something like how to set the value of cookie to be
object of array and whats the exact syntax of how to make this work after
copying the functions you've given.

Thanks.  



bmsterling wrote:
> 
> Vijay,
> I answered your question in your other posting.
> 
> On 9/25/07, Potluri <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> Hi,
>>   I'm having trouble storing array of objects into cookie like
>> var arr = [];
>> arr.push({index:1,name:"vijay"});
>> arr.push({index:2,name:"krish"});
>>
>> When I'm trying to store array of objects into cookie usin g jquery
>> cookie
>> plugin like
>> $.cookie("arrCookie",arr);, It's not storing array object but a string as
>> [object Object],[object Object] indeed.
>>
>> So, when I'm trying to retrieve the value in cookie its returning a
>> string
>> [object Object],[object Object] which is frustrating.
>>
>> Can anyone of you know a way to store array of objects into cookie.
>>
>> Thanks in advance.
>> Vijay
>> --
>> View this message in context:
>> http://www.nabble.com/Can-we-store-array-of-objects-into-cookie-tf4517321s15494.html#a12885643
>> Sent from the JQuery mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Benjamin Sterling
> http://www.KenzoMedia.com
> http://www.KenzoHosting.com
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Can-we-store-array-of-objects-into-cookie-tf4517321s15494.html#a12889163
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to