Modifying cookie to store some extra parameter (other costimized setting) for state saving

Modifying cookie to store some extra parameter (other costimized setting) for state saving

mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
edited July 2013 in General
How can I modify the cookie to store some extra parameters for e.g I have two combobox on my webpage I am interested to store these combobox values in state saving cookie.so when I get back to the page I'm able retained the combobox value

I have tried to edit cookie value string but it give me error while invoking

[quote]
"fnCookieCallback": function(sName, oData, sExpires, sPath) {
// Customise oData or sName or whatever else here
var cookieData = {}
cookieData.pageSettings = pageSettings;
cookieData.oData = oData;
return sName + "=" + JSON.stringify(cookieData) + "; expires=" + sExpires + "; path=" + sPath;
}
[/quote]

is there any way to read the cookie value on document.ready function ?? so I can read the pagesetting value before invoking the datatable.

Thanks

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    I'd suggest using fnStateSaveParams and fnStateLoadParams as that is what they are there for :-)

    Allan
  • mayurpatelmayurpatel Posts: 10Questions: 0Answers: 0
    edited July 2013
    Hi Allan

    I have modified my code something like below

    [code]
    "fnCookieCallback": function(sName, oData, sExpires, sPath) {
    // Customise oData or sName or whatever else here
    oData.oPageSetting = pageSettings;
    return sName + "=" + JSON.stringify(oData) + "; expires=" + sExpires + "; path=" + sPath;
    }
    [/code]

    it's works for me I can able to store the page settings object value in query string

    I want to retrieve this value (pageSettings) before invoking the data table because what ever I have stored in (pageSettings) that would be as a parameter to fetch data from database on initial load of the page.


    I have tried to use _fnReadCookie method on document.ready function but it is giving me error
    so How can I call this function ??
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    There isn't a public function to read the cookie itself back. As I say, use fnStateLoadParams if you want to get the parameters that were saved. That is what it was designed for.

    Allan
This discussion has been closed.