Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by CRW on Dec 22, 2008 08:31
open dhtmlx forum
saveOpenStates and multiple cookies

Thank you very much for the help in the past,

I am using saveOpenStates for a dynamically loaded treegrid (load on open), so instead of using the getOpenStates? (forgot the name) to restore the open items, I make a javascript array during making of the page that does it. I'm using PHP server side and having issues getting the correct cookie sometimes; it seems to be saving multiple cookies for slightly different urls ( ie /one/two, /one, /one/two/three) and so sometimes I cannot get the correct cookie from php $_COOKIE variable (but sometimes I do). Idealy, I'd like saveOpenStates to use one cookie no matter the exact url (same cookie for /one/two, /one/two/three, etc.).
Any help is appreciated.
Answer posted by Support on Dec 22, 2008 10:30
You can use first parameter of saveOpenState to define exact name of cookie

   grid.saveOpenStates("some"); //$_COOKIE["gridOpensome"]

If you not using first parameter , grid will use ID of HTML container, which may be auto-generated and result in non-consistent behavior as in your case. 
Answer posted by crw on Dec 22, 2008 11:07
I hope this is the correct link for replying

I have using the first parameter of saveOpenStates (I need to because I'm saving diffrent open states for diffrent states)


As you can see from the attachement

My firefox Cookies window looks something like this

Site    Cookie Name

sitename gridOpencookie1
sitename gridOpencookie1
sitename gridOpencookie2
sitename gridOpencookie1
sitename gridOpencookie1

Those cookie1 have differing paths but similair  (as in one will be /one/two/three, another /one/two, etc).
The issue is those multiple occurrences of cookie1 causing instable behaviour.
Clearing the cookie cache doesn't work because they come back



Answer posted by Support on Dec 23, 2008 02:51
It is pretty odd behavior, browser can't have mutliple cookies with the same name for the same domain.
When open state saved grid uses the same cookie name, which must result in changing of current value, instead of creating new one. 

Please check your server side code, there is possibility that it dupplicate cookies somehow.

Answer posted by Support on Dec 23, 2008 02:53
Which version of FF you are using?
Answer posted by crw on Dec 23, 2008 07:27
FF 3.0.5 (on a mac).

From what I can tell from googling, multiple cookies can be set for the same name as long as the paths are different. (A person can access the treegrid that sets a given cookie @ say /one/two/three and /one/two, but the paths seem to also be having cookies at /one, and /.. All of them should be using the same cookie!)
Answer posted by Support on Dec 23, 2008 08:16
If it helps - you can control path as 
  grid.saveOpenStates("some","path=/;"); 
The second parameter may contain additional parameters for cookie.
Answer posted on Dec 23, 2008 08:39
Oh, thanks!