- fixed some session and cookie bugs

This commit is contained in:
Exodus4D
2016-07-04 20:21:14 +02:00
parent b21dc0bd76
commit 347627db02
5 changed files with 33 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
<?php
session_name('pathfinder_session');
$f3 = require('app/lib/base.php');
// load main config

View File

@@ -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;
};
/**

View File

@@ -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
};

View File

@@ -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;
};
/**

View File

@@ -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
};