8
8
9
9
class User extends MysqlEntity{
10
10
11
- protected $ id ;
12
- protected $ login ;
13
- protected $ password ;
11
+ const COOKIE_NAME = ' leedStaySignedIn ' ;
12
+
13
+ protected $ id , $ login , $ password ;
14
14
protected $ TABLE_NAME = 'user ' ;
15
15
protected $ object_fields =
16
16
array (
@@ -131,7 +131,7 @@ static function existAuthToken($auth=null){
131
131
$ userManager = new User ();
132
132
$ users = $ userManager ->populate ('id ' );
133
133
$ 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 ];
135
135
foreach ($ users as $ user ){
136
136
if ($ user ->getToken ()==$ auth || strtolower ($ user ->login )===$ phpAuth ){
137
137
$ result = $ user ;
@@ -147,11 +147,11 @@ static function generateSalt() {
147
147
148
148
function setStayConnected () {
149
149
///@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 ' );
151
151
}
152
152
153
153
static function delStayConnected () {
154
- setcookie (' leedStaySignedIn ' , '' , -1 );
154
+ setcookie (self :: COOKIE_NAME , '' , -1 );
155
155
}
156
156
157
157
function getId (){
0 commit comments