@@ -35,7 +35,7 @@ function __construct( $config = []) {
35
35
'cookie_domain ' => ''
36
36
];
37
37
38
- // merge incomming config params
38
+ // merge incoming config params
39
39
$ this ->config = array_merge ( $ this ->config , $ config );
40
40
41
41
@@ -346,7 +346,11 @@ public static function implode_assoc($inner_glue, $outer_glue, $array) {
346
346
}
347
347
348
348
private function createCookie ($ cookie_name , $ cookie_value , $ expires = 0 , $ path = '/ ' , $ domain = '' ) {
349
-
349
+
350
+ $ samesite = 'lax ' ;
351
+ $ secure = false ;
352
+ $ httponly = false ;
353
+
350
354
if (! $ domain ) {
351
355
352
356
$ domain = $ this ->getSetting ( 'cookie_domain ' );
@@ -364,13 +368,28 @@ private function createCookie($cookie_name, $cookie_value, $expires = 0, $path =
364
368
sdk::debug (sprintf ('Setting cookie %s with values: %s under domain: %s ' , $ cookie_name , $ cookie_value , $ domain ));
365
369
366
370
// makes cookie to session cookie only
367
- if ( !$ this ->getSetting ( 'cookie_persistence ' ) ) {
371
+ if ( ! $ this ->getSetting ( 'cookie_persistence ' ) ) {
368
372
$ expires = 0 ;
369
373
}
370
-
371
- $ path .= '; SameSite=lax ' ;
372
-
373
- setcookie ($ cookie_name , $ cookie_value , $ expires , $ path , $ domain );
374
+
375
+ // check for php version to set samesite attribute.
376
+ //php 7.2
377
+ if (PHP_VERSION_ID < 70300 ) {
378
+
379
+ $ path .= '; SameSite= ' .$ samesite ;
380
+ setcookie ($ cookie_name , $ cookie_value , $ expires , $ path , $ domain );
381
+
382
+ } else {
383
+ //php 7.3+
384
+ setcookie ($ cookie_name , $ cookie_value , [
385
+ 'expires ' => $ expires ,
386
+ 'path ' => $ path ,
387
+ 'domain ' => $ domain ,
388
+ 'samesite ' => $ samesite ,
389
+ 'secure ' => $ secure ,
390
+ 'httponly ' => $ httponly ,
391
+ ]);
392
+ }
374
393
}
375
394
376
395
private function deleteCookie ($ cookie_name , $ path = '/ ' , $ domain = '' ) {
0 commit comments