Commit 9e813c08 authored by Dries's avatar Dries
Browse files

- Bugfix: when clean URLs are enabled, the cookie path was not always set correctly when the
user logged using the user block from within a subdirectory.  Patch by Ulf Rompe.
parent a8c6f0d0
...@@ -510,7 +510,7 @@ function user_auth_help_links() { ...@@ -510,7 +510,7 @@ function user_auth_help_links() {
/*** User features *********************************************************/ /*** User features *********************************************************/
function user_login($edit = array(), $msg = "") { function user_login($edit = array(), $msg = "") {
global $user; global $user, $base_url;
/* /*
** If we are already logged on, go to the user page instead. ** If we are already logged on, go to the user page instead.
...@@ -591,11 +591,12 @@ function user_login($edit = array(), $msg = "") { ...@@ -591,11 +591,12 @@ function user_login($edit = array(), $msg = "") {
** that the session won't expire. ** that the session won't expire.
*/ */
$path = preg_replace("/.+\/\/[^\/]+(.*)/", "\$1/", $base_url);
if ($edit["remember_me"]) { if ($edit["remember_me"]) {
setcookie(session_name(), session_id(), time() + 3600 * 24 * 365); setcookie(session_name(), session_id(), time() + 3600 * 24 * 365, $path);
} }
else { else {
setcookie(session_name(), session_id()); setcookie(session_name(), session_id(), FALSE, $path);
} }
/* /*
......
...@@ -510,7 +510,7 @@ function user_auth_help_links() { ...@@ -510,7 +510,7 @@ function user_auth_help_links() {
/*** User features *********************************************************/ /*** User features *********************************************************/
function user_login($edit = array(), $msg = "") { function user_login($edit = array(), $msg = "") {
global $user; global $user, $base_url;
/* /*
** If we are already logged on, go to the user page instead. ** If we are already logged on, go to the user page instead.
...@@ -591,11 +591,12 @@ function user_login($edit = array(), $msg = "") { ...@@ -591,11 +591,12 @@ function user_login($edit = array(), $msg = "") {
** that the session won't expire. ** that the session won't expire.
*/ */
$path = preg_replace("/.+\/\/[^\/]+(.*)/", "\$1/", $base_url);
if ($edit["remember_me"]) { if ($edit["remember_me"]) {
setcookie(session_name(), session_id(), time() + 3600 * 24 * 365); setcookie(session_name(), session_id(), time() + 3600 * 24 * 365, $path);
} }
else { else {
setcookie(session_name(), session_id()); setcookie(session_name(), session_id(), FALSE, $path);
} }
/* /*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment