-
April 22nd, 2012, 12:13 AM
#1
XML and Cookies
Hello,
Just wondering if you can store a XML file into a Cookie?
I have the following code:
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?
-
April 23rd, 2012, 03:40 AM
#2
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 way...you're still dealing with plain text.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
May 18th, 2012, 04:54 AM
#3
Re: XML and Cookies
Agree with but you can set the timeout of the cookie. This is temporary solution yet.
-
May 18th, 2012, 05:36 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|