From 347627db028c2ac182b412e1cf53a57afccfb0d9 Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Mon, 4 Jul 2016 20:21:14 +0200 Subject: [PATCH] - fixed some session and cookie bugs --- index.php | 1 + js/app/login.js | 3 ++- js/app/util.js | 14 ++++++++++++++ public/js/v1.1.1/app/login.js | 3 ++- public/js/v1.1.1/app/util.js | 14 ++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 8bcde159..21b3c22c 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ www.pathfinder.com/pathfinder/ -> /pathfinder + * @returns {string|string} + */ + var getDocumentPath = function(){ + var pathname = window.location.pathname; + // replace file endings + var r = /[^\/]*$/; + var path = pathname.replace(r, ''); + return path || '/'; + }; + /** * redirect * @param url @@ -1919,6 +1932,7 @@ define([ convertDateToString: convertDateToString, getOpenDialogs: getOpenDialogs, formatPrice: formatPrice, + getDocumentPath: getDocumentPath, redirect: redirect, logout: logout }; diff --git a/public/js/v1.1.1/app/login.js b/public/js/v1.1.1/app/login.js index ad257de6..d3baaab8 100644 --- a/public/js/v1.1.1/app/login.js +++ b/public/js/v1.1.1/app/login.js @@ -77,7 +77,8 @@ define([ var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = 'expires=' + d.toUTCString(); - document.cookie = cname + '=' + cvalue + '; ' + expires; + var path = 'path=' + Util.getDocumentPath(); + document.cookie = cname + '=' + cvalue + '; ' + expires + '; ' + path; }; /** diff --git a/public/js/v1.1.1/app/util.js b/public/js/v1.1.1/app/util.js index def5eb5c..102a6499 100644 --- a/public/js/v1.1.1/app/util.js +++ b/public/js/v1.1.1/app/util.js @@ -1824,6 +1824,19 @@ define([ return dateString + ' ' + timeString; }; + /** + * get document path + * -> www.pathfinder.com/pathfinder/ -> /pathfinder + * @returns {string|string} + */ + var getDocumentPath = function(){ + var pathname = window.location.pathname; + // replace file endings + var r = /[^\/]*$/; + var path = pathname.replace(r, ''); + return path || '/'; + }; + /** * redirect * @param url @@ -1919,6 +1932,7 @@ define([ convertDateToString: convertDateToString, getOpenDialogs: getOpenDialogs, formatPrice: formatPrice, + getDocumentPath: getDocumentPath, redirect: redirect, logout: logout };