Presentation logo

Safari Cookie Script DeprecatedDEPOSIT


Safari is known for blocking the cookies from 3rd party domains (domains that are not open directly, but within an iframe). This is causing the Cashier login issues, which are easy to recognize by the following message being shown to customer:

image

However this issue is easy to fix by silently navigating the customer to 3rd party domain and immediately sending him back - further the browser will recognize the domain as known.

This script can be implemented into your cashier form to fix error


function isSSL() {
    return window.location.protocol == 'https:';
}

function SetCookie(name, value, exdays) {
    var exp = new Date();
    exp.setDate(exp.getDate() + exdays);
    var c_value = encodeURIComponent(value) + ((exdays == null) ? "" : "; expires=" + exp.toUTCString());
    if (isSSL()) { c_value += "; secure"; }
    document.cookie = encodeURIComponent(name) + "=" + c_value;
}

// returns value of cookie or null if cookie does not exist
function GetCookie(name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == name) {
            return decodeURIComponent(y);
        }
    }
}

if ( navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 ){

    var cashiercookie = GetCookie("CashierCookie");

    if (cashiercookie == null) {
        SetCookie("CashierCookie", true, 1);
        var currentLocation = window.location.href;
        window.location.href = 'https://cashier.praxispay.com/BounceBack.asp?returnUri=' + encodeURIComponent(currentLocation);
    }
}