From 63bc9838cd41fd66d359a00c53ef476af303f3b4 Mon Sep 17 00:00:00 2001 From: chrisaga Date: Sat, 8 Jul 2006 09:27:23 +0000 Subject: fix bug 458: Cannot log due to broken session cookie (wrong "path") use $_SERVER['REDIRECT_URL'] if it's set add a trailing '/' git-svn-id: http://piwigo.org/svn/trunk@1442 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_session.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include/functions_session.inc.php') diff --git a/include/functions_session.inc.php b/include/functions_session.inc.php index 9768bf927..8765028ae 100644 --- a/include/functions_session.inc.php +++ b/include/functions_session.inc.php @@ -84,7 +84,12 @@ if (isset($conf['session_save_handler']) // cookie_path will return : "/meeting/gallery" function cookie_path() { - if ( isset($_SERVER['REDIRECT_URL']) ) + if ( isset($_SERVER['REDIRECT_SCRIPT_NAME']) and + !empty($_SERVER['REDIRECT_SCRIPT_NAME']) ) + { + $scr = $_SERVER['REDIRECT_SCRIPT_NAME']; + } + else if ( isset($_SERVER['REDIRECT_URL']) ) { // mod_rewrite is activated for upper level directories. we must set the // cookie to the path shown in the browser otherwise it will be discarded. if ( isset($_SERVER['PATH_INFO']) and !empty($_SERVER['PATH_INFO']) ) @@ -108,7 +113,9 @@ function cookie_path() { $scr = $_SERVER['SCRIPT_NAME']; } - return substr($scr,0,strrpos( $scr,'/')); + $scr = substr($scr,0,strrpos( $scr,'/')); + // add a trailing '/' if needed + return ($scr{strlen($scr)-1} == '/') ? $scr : $scr . '/'; } /** -- cgit v1.2.3