<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JSON JavaScript cookies</title>
	<atom:link href="http://www.phpied.com/json-javascript-cookies/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpied.com/json-javascript-cookies/</link>
	<description>Stoyan&#039;s blog about &#60;a href=&#34;/category/xhtml&#34; class=&#34;tag-minor&#34;&#62;(x)html(5)&#60;/a&#62;, &#60;a href=&#34;/category/ajax&#34; class=&#34;tag-major&#34;&#62;ajax&#60;/a&#62;, &#60;a href=&#34;/category/bookmarklets&#34; class=&#34;tag-major&#34;&#62;bookmarklets&#60;/a&#62;, &#60;a href=&#34;/category/browsers&#34; class=&#34;tag-minor&#34;&#62;browsers&#60;/a&#62;, &#60;a href=&#34;/category/css&#34; class=&#34;tag-normal&#34;&#62;css&#60;/a&#62;, &#60;a href=&#34;/category/firebug&#34; class=&#34;tag-minor&#34;&#62;firebug&#60;/a&#62;, &#60;a href=&#34;/category/javascript&#34; class=&#34;tag-numero-uno&#34;&#62;javascript&#60;/a&#62;, &#60;a href=&#34;/category/json&#34; class=&#34;tag-normal&#34;&#62;json&#60;/a&#62;, &#60;a href=&#34;/category/mdb2&#34; class=&#34;tag-minor&#34;&#62;mdb2&#60;/a&#62;, &#60;a href=&#34;/category/mysql&#34; class=&#34;tag-normal&#34;&#62;mysql&#60;/a&#62;, &#60;a href=&#34;/category/pear&#34; class=&#34;tag-numero-uno&#34;&#62;pear&#60;/a&#62;, &#60;a href=&#34;/category/performance&#34; class=&#34;tag-major&#34;&#62;performance&#60;/a&#62;, &#60;a href=&#34;/category/php&#34; class=&#34;tag-numero-uno&#34;&#62;php&#60;/a&#62;, &#60;a href=&#34;/category/phpbb&#34; class=&#34;tag-major&#34;&#62;phpbb&#60;/a&#62;, &#60;a href=&#34;/category/tools&#34; class=&#34;tag-normal&#34;&#62;tools&#60;/a&#62;, &#60;a href=&#34;/category/yslow&#34; class=&#34;tag-minor&#34;&#62;yslow&#60;/a&#62;, &#60;a href=&#34;/category/yui&#34; class=&#34;tag-normal&#34;&#62;yui&#60;/a&#62;, &#60;a href=&#34;/category/writing&#34; class=&#34;tag-minor&#34;&#62;writing&#60;/a&#62;, &#60;a href=&#34;/category/music&#34; class=&#34;tag-major&#34;&#62;music&#60;/a&#62;,... &#60;a href=&#34;/category/life-and-everything&#34; class=&#34;tag-normal&#34;&#62;life and everything&#60;/a&#62;.</description>
	<lastBuildDate>Sat, 11 Feb 2012 14:07:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	<item>
		<title>By: Watch The Simpsons – Season 23, Episode 6: The Book Job</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-80025</link>
		<dc:creator>Watch The Simpsons – Season 23, Episode 6: The Book Job</dc:creator>
		<pubDate>Mon, 21 Nov 2011 22:21:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-80025</guid>
		<description>&lt;strong&gt;Watch The Simpsons – Season 23, Episode 6: The Book Job...&lt;/strong&gt;

[...]JSON JavaScript cookies / Stoyan&#039;s phpied.com[...]...</description>
		<content:encoded><![CDATA[<p><strong>Watch The Simpsons – Season 23, Episode 6: The Book Job&#8230;</strong></p>
<p>[...]JSON JavaScript cookies / Stoyan&#8217;s phpied.com[...]&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-78417</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Sat, 06 Aug 2011 11:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-78417</guid>
		<description>Do not forget the size limit of cookies!</description>
		<content:encoded><![CDATA[<p>Do not forget the size limit of cookies!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barney</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-78394</link>
		<dc:creator>Barney</dc:creator>
		<pubDate>Mon, 01 Aug 2011 09:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-78394</guid>
		<description>Stoyan, in many situations a &#039;global&#039; cookie will already be in use by underlying frameworks — for example, I am currently working on a .net webforms monstrosity where the first item of document.cookie.split(&#039;;&#039;) is none of my business.

In these situations, the JSON parser will break attempting to evaluate key=value pairs.

Having said that, it&#039;s generally safe to assume that the last item of the arrayified cookie will be the one we&#039;re after. I made the following modification in my implementation:

this.data = unescape(the_cookie[the_cookie.length-1]).parseJSON();

…or, using Saurus&#039; JSON2 syntax:

this.data = JSON.parse(unescape(the_cookie[the_cookie.length-1]));</description>
		<content:encoded><![CDATA[<p>Stoyan, in many situations a &#8216;global&#8217; cookie will already be in use by underlying frameworks — for example, I am currently working on a .net webforms monstrosity where the first item of document.cookie.split(&#8216;;&#8217;) is none of my business.</p>
<p>In these situations, the JSON parser will break attempting to evaluate key=value pairs.</p>
<p>Having said that, it&#8217;s generally safe to assume that the last item of the arrayified cookie will be the one we&#8217;re after. I made the following modification in my implementation:</p>
<p>this.data = unescape(the_cookie[the_cookie.length-1]).parseJSON();</p>
<p>…or, using Saurus&#8217; JSON2 syntax:</p>
<p>this.data = JSON.parse(unescape(the_cookie[the_cookie.length-1]));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saurus</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-77307</link>
		<dc:creator>Saurus</dc:creator>
		<pubDate>Tue, 05 Apr 2011 23:12:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-77307</guid>
		<description>FOR JSON2

var prefs = {
    data: {},
    load: function () {
        var the_cookie = document.cookie.split(&#039;;&#039;);
        if (the_cookie[0]) {
            this.data = JSON.parse(unescape(the_cookie[0]));
        }
        return this.data;
    },
    save: function (expires, path) {
        var d = expires &#124;&#124; new Date(2030, 02, 02);
        var p = path &#124;&#124; &#039;/&#039;;
        document.cookie = escape(JSON.stringify(this.data))
                          + &#039;;path=&#039; + p
                          + &#039;;expires=&#039; + d.toUTCString();
    }
}</description>
		<content:encoded><![CDATA[<p>FOR JSON2</p>
<p>var prefs = {<br />
    data: {},<br />
    load: function () {<br />
        var the_cookie = document.cookie.split(&#8216;;&#8217;);<br />
        if (the_cookie[0]) {<br />
            this.data = JSON.parse(unescape(the_cookie[0]));<br />
        }<br />
        return this.data;<br />
    },<br />
    save: function (expires, path) {<br />
        var d = expires || new Date(2030, 02, 02);<br />
        var p = path || &#8216;/&#8217;;<br />
        document.cookie = escape(JSON.stringify(this.data))<br />
                          + &#8216;;path=&#8217; + p<br />
                          + &#8216;;expires=&#8217; + d.toUTCString();<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-72839</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 05 May 2010 15:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-72839</guid>
		<description>I&#039;m trying to implement this on a different platform. Putting json data directly into a cookie will break it. I&#039;ve had to base64 it. Just thought I&#039;d point this out. Also, would there be a better method than base64? What characters are allowed in a cookie string and how do you escape them?</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to implement this on a different platform. Putting json data directly into a cookie will break it. I&#8217;ve had to base64 it. Just thought I&#8217;d point this out. Also, would there be a better method than base64? What characters are allowed in a cookie string and how do you escape them?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Web Interface con Troyanos - Todo Dream</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-71798</link>
		<dc:creator>Web Interface con Troyanos - Todo Dream</dc:creator>
		<pubDate>Tue, 17 Nov 2009 21:27:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-71798</guid>
		<description>[...] voici le code complet dans la page web de ma dream /* * This code is inspired by JSON JavaScript cookies / Stoyan&#039;s phpied.com * and modified for use with prototype * It&#039;s a pretty straight forward way to store and load [...]</description>
		<content:encoded><![CDATA[<p>[...] voici le code complet dans la page web de ma dream /* * This code is inspired by JSON JavaScript cookies / Stoyan&#8217;s phpied.com * and modified for use with prototype * It&#8217;s a pretty straight forward way to store and load [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Week Twelve exercise &#60; Dreamweaver</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-71788</link>
		<dc:creator>Week Twelve exercise &#60; Dreamweaver</dc:creator>
		<pubDate>Mon, 16 Nov 2009 17:30:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-71788</guid>
		<description>[...] JSON JavaScript cookies @ [...]</description>
		<content:encoded><![CDATA[<p>[...] JSON JavaScript cookies @ [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Top 10 links to study JavaScript Cookies &#124; Webpru</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-71699</link>
		<dc:creator>Top 10 links to study JavaScript Cookies &#124; Webpru</dc:creator>
		<pubDate>Wed, 28 Oct 2009 03:00:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-71699</guid>
		<description>[...] 9.http://www.phpied.com/json-javascript-cookies/ [...]</description>
		<content:encoded><![CDATA[<p>[...] 9.<a href="http://www.phpied.com/json-javascript-cookies/" rel="nofollow">http://www.phpied.com/json-javascript-cookies/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Napolux</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-71291</link>
		<dc:creator>Napolux</dc:creator>
		<pubDate>Fri, 07 Aug 2009 12:55:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-71291</guid>
		<description>Really nice implementation. I&#039;ll try ASAP ;)</description>
		<content:encoded><![CDATA[<p>Really nice implementation. I&#8217;ll try ASAP <img src='http://www.phpied.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sj</title>
		<link>http://www.phpied.com/json-javascript-cookies/#comment-70585</link>
		<dc:creator>sj</dc:creator>
		<pubDate>Mon, 23 Mar 2009 17:50:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.phpied.com/json-javascript-cookies/#comment-70585</guid>
		<description>This does not work anymore.

You get a javascript error with IE</description>
		<content:encoded><![CDATA[<p>This does not work anymore.</p>
<p>You get a javascript error with IE</p>
]]></content:encoded>
	</item>
</channel>
</rss>

