{"id":1138,"date":"2013-02-16T19:47:04","date_gmt":"2013-02-17T00:47:04","guid":{"rendered":"http:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/?p=1138"},"modified":"2013-02-16T19:47:04","modified_gmt":"2013-02-17T00:47:04","slug":"javascript-cookies","status":"publish","type":"post","link":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2013\/02\/javascript-cookies\/","title":{"rendered":"JavaScript Cookies"},"content":{"rendered":"<p>People of Earth! \u00a0Cookies will not be saved by your browser when operating from a local <code>file:\/\/<\/code> URL! \u00a0Do not waste time writing your own little cookie functions out of the forlorn, astounded believe that everyone else out there, e.g., jQuery, is somehow just crazy and doing something wrong!<\/p>\n<pre>function getCookie(get)\r\n{\r\n  var cookies = document.cookie.split(\";\");\r\n  var i, name;\r\n  for (i = 0; i &lt; cookies.length; i++) {\r\n    name = cookies[i].substr(0,cookies[i].indexOf(\"=\"))\r\n      .replace(\/^\\s+|\\s+$\/g,\"\");\r\n    if (name == get) {\r\n      return unescape(cookies[i].substr(cookies[i].indexOf(\"=\")+1));\r\n    }\r\n  }\r\n  return null;\r\n}\r\n\r\nfunction setCookie(name, value, days)\r\n{\r\n  var expDate = new Date();\r\n  expDate.setDate(expDate.getDate() + days);\r\n  var cookie = escape(value) +\r\n               ((days==null) ? \"\" : \"; expires=\"+expDate.toUTCString());\r\n  document.cookie = name + \"=\" + cookie;\r\n}\r\n\r\nfunction deleteCookie(name)\r\n{\r\n  setCookie(name, null, -1);\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>People of Earth! \u00a0Cookies will not be saved by your browser when operating from a local file:\/\/ URL! \u00a0Do not waste time writing your own little cookie functions out of the forlorn, astounded believe that everyone else out there, e.g., jQuery, is somehow just crazy and doing something wrong! function getCookie(get) { var cookies = &hellip; <a href=\"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/2013\/02\/javascript-cookies\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[165,164,162,294],"class_list":["post-1138","post","type-post","status-publish","format-standard","hentry","category-code","tag-cookies","tag-html","tag-javascript","tag-web-design"],"_links":{"self":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/1138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/comments?post=1138"}],"version-history":[{"count":1,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/1138\/revisions"}],"predecessor-version":[{"id":1139,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/posts\/1138\/revisions\/1139"}],"wp:attachment":[{"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/media?parent=1138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/categories?post=1138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rocketshipgames.com\/blogs\/tjkopena\/wp-json\/wp\/v2\/tags?post=1138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}