From 6ac2a044263f50c48f101af3f9df4a47fe823003 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Wed, 20 Jan 2010 22:42:10 +0000 Subject: Futon: Prefix cookie names with the port number, so that different CouchDB instances accessed through the same host name but different ports get their own storage. Closes COUCHDB-533. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@901413 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/futon.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'share') diff --git a/share/www/script/futon.js b/share/www/script/futon.js index ce7de02e..005fe032 100644 --- a/share/www/script/futon.js +++ b/share/www/script/futon.js @@ -160,7 +160,8 @@ } this.addDatabase = function(name) { - var recentDbs = $.futon.storage.get("recent", "").split(","); + var current = $.futon.storage.get("recent", ""); + var recentDbs = current ? current.split(",") : []; if ($.inArray(name, recentDbs) == -1) { recentDbs.unshift(name); if (recentDbs.length > 10) recentDbs.length = 10; @@ -171,7 +172,8 @@ this.removeDatabase = function(name) { // remove database from recent databases list - var recentDbs = $.futon.storage.get("recent").split(","); + var current = $.futon.storage.get("recent", ""); + var recentDbs = current ? current.split(",") : []; var recentIdx = $.inArray(name, recentDbs); if (recentIdx >= 0) { recentDbs.splice(recentIdx, 1); @@ -309,11 +311,14 @@ return callback(decl); } + // add suffix to cookie names to be able to separate between ports + var cookiePrefix = location.port + "_"; + var handlers = { "cookie": { get: function(name) { - var nameEq = name + "="; + var nameEq = cookiePrefix + name + "="; var parts = document.cookie.split(';'); for (var i = 0; i < parts.length; i++) { var part = parts[i].replace(/^\s+/, ""); @@ -325,13 +330,14 @@ set: function(name, value) { var date = new Date(); date.setTime(date.getTime() + 14*24*60*60*1000); // two weeks - document.cookie = name + "=" + escape(value) + "; expires=" + - date.toGMTString(); + document.cookie = cookiePrefix + name + "=" + escape(value) + + "; domain=" + location.hostname + "; expires=" + date.toGMTString(); }, del: function(name) { var date = new Date(); date.setTime(date.getTime() - 24*60*60*1000); // yesterday - document.cookie = name + "=; expires=" + date.toGMTString(); + document.cookie = cookiePrefix + name + "=; domain=" + + location.hostname + "; expires=" + date.toGMTString(); } }, -- cgit v1.2.3