CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: XML and Cookies

  1. #1
    Join Date
    Mar 2006

    Question XML and Cookies


    Just wondering if you can store a XML file into a Cookie?

    I have the following code:
    function setCookie(c_name,value,exdays)
     var exdate=new Date();
     exdate.setDate(exdate.getDate() + exdays);
     var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
     document.cookie=c_name + "=" + c_value;
    just wondering if you can store a XML file into a cookie so that I can load the whole xml file from the cookie rather than loading the XML file again?

    Anyone able to help?

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: XML and Cookies

    Sorry. Cookies store raw strings. You could use JSON and serialize the XML as an object, then convert back to XML after. But, either're still dealing with plain text.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2012

    Re: XML and Cookies

    Agree with but you can set the timeout of the cookie. This is temporary solution yet.

  4. #4
    Join Date
    May 2012
    Bonn, Germany

    Re: XML and Cookies

    While you can store XML text in a cookie, it might not be the best idea.
    XML means a lot of overhead and if you want to store a lot of data, you can reach the 4 KB limit quickly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)