Makes cookie path overridable

Change-Id: I3244103a72fbb994597af08df233f0237eb28f18
diff --git a/dev/js/spec/sessionSpec.js b/dev/js/spec/sessionSpec.js
index 96f45cb..6c10d9a 100644
--- a/dev/js/spec/sessionSpec.js
+++ b/dev/js/spec/sessionSpec.js
@@ -55,7 +55,23 @@
       expect(document.cookie.includes("koraptest=%7B%22test3%22%3A%22works%22%7D")).toBeTruthy();
       s.clear();     
       expect(document.cookie.includes("koraptest=")).toBeTruthy();
-      expect(s.toString()).toEqual("koraptest=%7B%7D;SameSite=Lax");
-    });   
+      expect(s.toString()).toEqual("koraptest=%7B%7D;SameSite=Lax;path=/");
+    }); 
+    
+    /*
+    * The cookie path should by default be '/'. The path should be settable.
+    */
+    it('cookie path should have default and be settable', function(){
+      //cookie should be created with the default path=/
+      let c = sessionClass.create("cookwithoutp");
+      c.clear();
+      expect(c.toString().includes("path=/")).toBeTruthy();
+      //the path should be settable
+      let d =  sessionClass.create("cookwithp", "/instance/blub");
+      d.clear();
+      expect(d.toString().includes("path=/instance/blub")).toBeTruthy();
+    });
+
   })
+
 });
diff --git a/dev/js/src/session.js b/dev/js/src/session.js
index 3c9d457..fe8de4c 100644
--- a/dev/js/src/session.js
+++ b/dev/js/src/session.js
@@ -11,10 +11,12 @@
   /**
    * Create a new session.
    * Expects a name or defaults to 'korap'
+   * Expects a path or defaults to '/'
    */
-  create : function (name = 'korap') {
+  create : function (name = 'korap', path ="/") {
     const obj = Object.create(this);
     obj._name = name.toLowerCase();
+    obj._path = path;
     obj._hash = {};
     obj._parse();
     return obj;
@@ -38,7 +40,7 @@
     this._hash[key] = value;
     this._store();
   },
-
+ 
 
   /**
    * Clears the session by removing the cookie
@@ -63,7 +65,7 @@
       var date = new Date();
       date.setYear(date.getFullYear() + 1);
     */
-    return this._name + '=' + encodeURIComponent(JSON.stringify(this._hash)) + ';SameSite=Lax' + ';path=/';
+    return this._name + '=' + encodeURIComponent(JSON.stringify(this._hash)) + ';SameSite=Lax' + ';path='+this._path;
   },