Browse code

user/login.php: restore original setcookie behavior (remember me cookies) for PHP versions older than 7.3.0

Clarissa Walker authored on 2026/11/21 15:34:41
Showing 1 changed files
... ...
@@ -67,8 +67,14 @@
67 67
 		}
68 68
 		if(password_verify($_POST['password'], $encryptedpasswordb)) {
69 69
 			if(isset($_POST['cookiecheck'])) {
70
-				setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
71
-				setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordb), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
70
+				if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
71
+					setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
72
+					setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordb), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
73
+				}
74
+				else {
75
+					setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
76
+					setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordb), time()+60*60*24*30, "/");
77
+				}
72 78
 			}
73 79
 			// as of CVE-2026-115560, you can no longer set these settings if
74 80
 			// session.upload_progress.enabled is set to 'On'
... ...
@@ -92,8 +98,14 @@
92 98
 
93 99
 		else if($passwd['password'] == $encryptedpasswordm) {
94 100
 			if(isset($_POST['cookiecheck'])) {
95
-				setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
96
-				setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordm), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
101
+				if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
102
+					setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
103
+					setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordm), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
104
+				}
105
+				else {
106
+					setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
107
+					setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpasswordm), time()+60*60*24*30, "/");
108
+				}
97 109
 			}
98 110
 			// as of CVE-2026-115560, you can no longer set these settings if
99 111
 			// session.upload_progress.enabled is set to 'On'