Browse code

header.php, user.php, user/login.php: Security - Session and Remember Me cookies are now marked httponly and Lax, previously nonexistent - from @ariadoss

Clarissa Walker authored on 2026/10/26 21:25:45
Showing 3 changed files
... ...
@@ -50,7 +50,11 @@ foreach ($_GET as $v) {
50 50
 }
51 51
 unset($v);
52 52
 
53
-if(!isset($_SESSION)) session_start();
53
+if(!isset($_SESSION)) {
54
+	ini_set('session.cookie_httponly', '1');
55
+	ini_set('session.cookie_samesite', 'Lax');
56
+	session_start();
57
+}
54 58
 // clear the global variables if register globals is on.
55 59
 if(ini_get('register_globals')) {
56 60
 	$arrayList = array_merge($_SESSION, $_GET, $_POST, $_COOKIE);
... ...
@@ -28,6 +28,8 @@ else $current = "login";
28 28
 	}
29 29
 	
30 30
 	if(!empty($_POST['submit']) && $current == "login") {
31
+	ini_set('session.cookie_httponly', '1');
32
+	ini_set('session.cookie_samesite', 'Lax');
31 33
 	session_start();
32 34
 	define("_LOGINCHECK", true);		
33 35
 		include("user/login.php");
... ...
@@ -66,10 +66,15 @@
66 66
 		}
67 67
 		if($passwd['password'] == $encryptedpassword) {
68 68
 			if(isset($_POST['cookiecheck'])) {
69
-				setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
70
-				setcookie($sitekey."_salt", md5($passwd['email'] . $encryptedpassword),  time()+60*60*24*30, "/");
69
+				setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
70
+				setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpassword), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
71
+			}
72
+			if(!isset($_SESSION)) {
73
+				// Maintenance fork: match header.php's httponly/Lax session cookie.
74
+				ini_set('session.cookie_httponly', '1');
75
+				ini_set('session.cookie_samesite', 'Lax');
76
+				session_start( );
71 77
 			}
72
-			if(!isset($_SESSION)) session_start( );
73 78
 			session_regenerate_id(true);
74 79
 			$_SESSION[$sitekey."_useruid"] = $passwd['uid'];
75 80
 			$_SESSION[$sitekey."_salt"] = md5($passwd['email'] . $encryptedpassword);