Hack for chrome: catch errors when reading/writing cookies

and just treat it as if there is no cookie.  This is what
chrome effectively did until recently -- so the relying on
cookies for the return path to the user-specific pages was
and still is broken.

svn: r18684

original commit: 658fc0717d470d0b4f4cf1f19cec4a5ff3336187
This commit is contained in:
Eli Barzilay 2010-03-31 06:36:58 +00:00
parent 7b5f74a788
commit eadb5fec07

View File

@ -54,8 +54,11 @@ function MergePageArgsIntoLink(a) {
// Cookies --------------------------------------------------------------------
function GetCookie(key, def) {
if (document.cookie.length <= 0) return def;
var i, cookiestrs = document.cookie.split(/; */);
var i, cookiestrs;
try {
if (document.cookie.length <= 0) return def;
cookiestrs = document.cookie.split(/; */);
} catch (e) { return def; }
for (i = 0; i < cookiestrs.length; i++) {
var cur = cookiestrs[i];
var eql = cur.indexOf('=');
@ -68,8 +71,10 @@ function GetCookie(key, def) {
function SetCookie(key, val) {
var d = new Date();
d.setTime(d.getTime()+(365*24*60*60*1000));
document.cookie =
key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/";
try {
document.cookie =
key + "=" + escape(val) + "; expires="+ d.toGMTString() + "; path=/";
} catch (e) {}
}
// note that this always stores a directory name, ending with a "/"