Documentation

CRM_Utils_SameSite
in package

SameSite Utility Class.

Determines if the current User Agent can handle the SameSite=None parameter by mapping against known incompatible clients.

Sample code:

// Get User Agent string. $rawUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; $userAgent = mb_convert_encoding($rawUserAgent, 'UTF-8');

// Get boolean representing User Agent compatibility. $shouldUseSameSite = CRM_Utils_SameSite::shouldSendSameSiteNone($userAgent);

Based on code provided by "The Chromium Projects".

Tags
see
https://www.chromium.org/updates/same-site/incompatible-clients

Table of Contents

Methods

shouldSendSameSiteNone()  : bool
Determine if the current User Agent can handle the `SameSite=None` parameter.
dropsUnrecognizedSameSiteCookies()  : bool
Detect versions of UC Browser on Android prior to version 12.13.2.
hasWebKitSameSiteBug()  : bool
Detect versions of Safari and embedded browsers on MacOS 10.14 and all browsers on iOS 12.
isChromiumBased()  : false|int
Detect if browser is Chromium based.
isChromiumVersionAtLeast()  : bool|int
Detect if Chromium version meets requirements.
isIosVersion()  : bool
Detect iOS version.
isMacEmbeddedBrowser()  : false|int
Detect MacOS embedded browser.
isMacosxVersion()  : bool
Detect MacOS version.
isSafari()  : bool
Detect MacOS Safari.
isSameSiteNoneIncompatible()  : bool
Detect classes of browsers known to be incompatible.
isUcBrowser()  : false|int
Detect UCBrowser.
isUcBrowserVersionAtLeast()  : bool|int
Detect if UCBrowser version meets requirements.

Methods

shouldSendSameSiteNone()

Determine if the current User Agent can handle the `SameSite=None` parameter.

public static shouldSendSameSiteNone(string $userAgent) : bool
Parameters
$userAgent : string
Return values
bool

True if the User Agent is compatible, FALSE otherwise.

dropsUnrecognizedSameSiteCookies()

Detect versions of UC Browser on Android prior to version 12.13.2.

private static dropsUnrecognizedSameSiteCookies(string $userAgent) : bool

Older versions will reject a cookie with SameSite=None. This behavior was correct according to the version of the cookie specification at that time, but with the addition of the new "None" value to the specification, this behavior has been updated in newer versions of UC Browser.

Parameters
$userAgent : string

The User Agent.

Return values
bool

hasWebKitSameSiteBug()

Detect versions of Safari and embedded browsers on MacOS 10.14 and all browsers on iOS 12.

private static hasWebKitSameSiteBug(string $userAgent) : bool

These versions will erroneously treat cookies marked with SameSite=None as if they were marked SameSite=Strict.

Parameters
$userAgent : string

The User Agent.

Return values
bool

isChromiumBased()

Detect if browser is Chromium based.

private static isChromiumBased(string $userAgent) : false|int
Parameters
$userAgent : string

The User Agent.

Return values
false|int

isChromiumVersionAtLeast()

Detect if Chromium version meets requirements.

private static isChromiumVersionAtLeast(int $major, string $userAgent, string $operator) : bool|int
Parameters
$major : int

The major version to test.

$userAgent : string

The User Agent.

$operator : string
Return values
bool|int

isIosVersion()

Detect iOS version.

private static isIosVersion(int $major, string $userAgent) : bool
Parameters
$major : int

The major version to test.

$userAgent : string

The User Agent.

Return values
bool

isMacEmbeddedBrowser()

Detect MacOS embedded browser.

private static isMacEmbeddedBrowser(string $userAgent) : false|int
Parameters
$userAgent : string

The User Agent.

Return values
false|int

isMacosxVersion()

Detect MacOS version.

private static isMacosxVersion(int $major, int $minor, string $userAgent) : bool
Parameters
$major : int

The major version to test.

$minor : int

The minor version to test.

$userAgent : string

The User Agent.

Return values
bool

isSafari()

Detect MacOS Safari.

private static isSafari(string $userAgent) : bool
Parameters
$userAgent : string

The User Agent.

Return values
bool

isSameSiteNoneIncompatible()

Detect classes of browsers known to be incompatible.

private static isSameSiteNoneIncompatible(string $userAgent) : bool
Parameters
$userAgent : string

The User Agent.

Return values
bool

True if the User Agent is determined to be incompatible, FALSE otherwise.

isUcBrowser()

Detect UCBrowser.

private static isUcBrowser(string $userAgent) : false|int
Parameters
$userAgent : string

The User Agent.

Return values
false|int

isUcBrowserVersionAtLeast()

Detect if UCBrowser version meets requirements.

private static isUcBrowserVersionAtLeast(int $major, int $minor, int $build, string $userAgent) : bool|int
Parameters
$major : int

The major version to test.

$minor : int

The minor version to test.

$build : int

The build version to test.

$userAgent : string

The User Agent.

Return values
bool|int

        
On this page

Search results