Skip to content

Commit 64507f9

Browse files
committed
Cookie posé avec la directive SameSite: Strict
1 parent ddc2d80 commit 64507f9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

User.class.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
class User extends MysqlEntity{
1010

11-
protected $id;
12-
protected $login;
13-
protected $password;
11+
const COOKIE_NAME = 'leedStaySignedIn';
12+
13+
protected $id,$login,$password;
1414
protected $TABLE_NAME = 'user';
1515
protected $object_fields =
1616
array(
@@ -131,7 +131,7 @@ static function existAuthToken($auth=null){
131131
$userManager = new User();
132132
$users = $userManager->populate('id');
133133
$phpAuth = isset($_SERVER['PHP_AUTH_USER']) ? strtolower($_SERVER['PHP_AUTH_USER']) : false;
134-
if (empty($auth)) $auth = @$_COOKIE['leedStaySignedIn'];
134+
if (empty($auth)) $auth = @$_COOKIE[self::COOKIE_NAME];
135135
foreach($users as $user){
136136
if ($user->getToken()==$auth || strtolower($user->login)===$phpAuth){
137137
$result = $user;
@@ -147,11 +147,11 @@ static function generateSalt() {
147147

148148
function setStayConnected() {
149149
///@TODO: set the current web directory, here and on del
150-
setcookie('leedStaySignedIn', $this->getToken(), time()+31536000);
150+
header('Set-Cookie: ' . self::COOKIE_NAME . '=' . $this->getToken() . '; Expires=' . gmdate('D, d-M-Y H:i:s', time()+31536000) . '; Max-Age=31536000; SameSite=Strict');
151151
}
152152

153153
static function delStayConnected() {
154-
setcookie('leedStaySignedIn', '', -1);
154+
setcookie(self::COOKIE_NAME, '', -1);
155155
}
156156

157157
function getId(){

0 commit comments

Comments
 (0)