Use windowId when storing session cookie
authorJakub Skoczen <jakub@indexdata.dk>
Thu, 12 Jun 2014 10:52:24 +0000 (12:52 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Thu, 12 Jun 2014 10:52:24 +0000 (12:52 +0200)
js/pz2.js

index 59c501d..fb6264c 100644 (file)
--- a/js/pz2.js
+++ b/js/pz2.js
@@ -769,7 +769,7 @@ pz2.prototype =
 ** AJAX HELPER CLASS ***********************************************************
 ********************************************************************************
 */
-var pzHttpRequest = function (url, errorHandler, cookieDomain) {
+var pzHttpRequest = function (url, errorHandler, cookieDomain, windowId) {
         this.maxUrlLength = 2048;
         this.request = null;
         this.url = url;
@@ -779,6 +779,7 @@ var pzHttpRequest = function (url, errorHandler, cookieDomain) {
         this.isXDR = false;
         this.domainRegex = /https?:\/\/([^:/]+).*/;
         this.cookieDomain = cookieDomain || null;
+        this.windowId = windowId || window.name;
 
         var xhr = new XMLHttpRequest();
         var domain = this._getDomainFromUrl(url);
@@ -906,9 +907,9 @@ pzHttpRequest.prototype =
         //session cookie, resend it
         var domain = this._getDomainFromUrl(url);
         if (domain && this._isCrossDomain(domain) &&
-            this.getCookie(domain+":SESSID")) {
+            this.getCookie(domain+":"+this.windowId+":SESSID")) {
           //rewrite the URL
-          var sessparam = ';jsessionid=' + this.getCookie(domain+":SESSID");
+          var sessparam = ';jsessionid=' + this.getCookie(domain+":"+this.windowId+":SESSID");
           var q = url.indexOf('?');
           if (q == -1) {
             url += sessparam;            
@@ -1020,7 +1021,7 @@ pzHttpRequest.prototype =
                   var jsessionId = this.request.responseXML
                     .documentElement.getAttribute('jsessionId');
                   if (jsessionId)                  
-                    this.setCookie(domain+":SESSID", jsessionId);
+                    this.setCookie(domain+":"+this.windowId+":SESSID", jsessionId);
                 }
                 this.callback(this.request.responseXML);
             } else {