Skip to content

Commit

Permalink
Merge pull request Shardj#7 from abhishek-algoworks/FE-336-sf-agent-p…
Browse files Browse the repository at this point in the history
…anel-classic-login-fails-in-chrome

DTPORTAL-19293 SF Agent Panel (Classic) - Login fails in Chrome
  • Loading branch information
mattcar authored Sep 28, 2020
2 parents 031b14b + 0e72612 commit ca426e1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions library/Zend/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ public static function regenerateId()
} else {
if (!self::$_unitTestEnabled) {
session_regenerate_id(true);

// Force Samesite cookie
self::sameSiteCookieWorkaroundPrePhp74();
}
self::$_regenerateIdState = 1;
}
Expand Down Expand Up @@ -485,6 +488,9 @@ public static function start($options = false)

$startedCleanly = session_start();

// Force Samesite cookie
self::sameSiteCookieWorkaroundPrePhp74();

if (self::$_throwStartupExceptions) {
restore_error_handler();
}
Expand Down Expand Up @@ -914,4 +920,25 @@ public static function isReadable()
return parent::$_readable;
}

/**
* @todo Remove definition and calls after upgrade to PHP 7.4
*
* This can be removed once we update to 7.4 or above as then
* we can use php.ini directive to achieve the same `session.cookie_samesite=None`
*/
public static function sameSiteCookieWorkaroundPrePhp74()
{
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
setcookie('IFBYPHONE', self::getId(), 0, '/; SameSite=None; HttpOnly; Secure');
} else {
setcookie('IFBYPHONE', self::getId(), [
'expires' => 0,
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'None'
]);
}
}

}

0 comments on commit ca426e1

Please sign in to comment.