header.php, user.php, user/login.php: Security - Session and Remember Me cookies are now marked httponly and Lax, previously nonexistent - from @ariadoss
--- a/header.php
+++ b/header.php
@@ -50,7 +50,11 @@
}
unset($v);
-if(!isset($_SESSION)) session_start();
+if(!isset($_SESSION)) {
+ ini_set('session.cookie_httponly', '1');
+ ini_set('session.cookie_samesite', 'Lax');
+ session_start();
+}
// clear the global variables if register globals is on.
if(ini_get('register_globals')) {
$arrayList = array_merge($_SESSION, $_GET, $_POST, $_COOKIE);
--- a/user.php
+++ b/user.php
@@ -28,6 +28,8 @@
}
if(!empty($_POST['submit']) && $current == "login") {
+ ini_set('session.cookie_httponly', '1');
+ ini_set('session.cookie_samesite', 'Lax');
session_start();
define("_LOGINCHECK", true);
include("user/login.php");
--- a/user/login.php
+++ b/user/login.php
@@ -66,10 +66,15 @@
}
if($passwd['password'] == $encryptedpassword) {
if(isset($_POST['cookiecheck'])) {
- setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
- setcookie($sitekey."_salt", md5($passwd['email'] . $encryptedpassword), time()+60*60*24*30, "/");
+ setcookie($sitekey."_useruid", $passwd['uid'], array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
+ setcookie($sitekey."_salt", md5($passwd['email'].$encryptedpassword), array('expires' => time()+60*60*24*30, 'path' => "/", 'httponly' => true, 'samesite' => 'Lax'));
}
- if(!isset($_SESSION)) session_start( );
+ if(!isset($_SESSION)) {
+ // Maintenance fork: match header.php's httponly/Lax session cookie.
+ ini_set('session.cookie_httponly', '1');
+ ini_set('session.cookie_samesite', 'Lax');
+ session_start( );
+ }
session_regenerate_id(true);
$_SESSION[$sitekey."_useruid"] = $passwd['uid'];
$_SESSION[$sitekey."_salt"] = md5($passwd['email'] . $encryptedpassword);