How to overcome Safari Third Party Cookie Policy

Problem

A session can not be started with unblu API when using Safari with default setting. How I can solve this issue?

Solution

First of all, the Safari third party cookie policy is some thing that has effect on most web sites, which include scripts or widgets or any other features from third-party sources.
Many websites include third party sources to provide services such as personalization or social interaction or co-browsing or live-chat.

For instance, your website may include the ?Like? button, in turn your page may either directly create an iframe pointing it to a Like button URL on Facebook or include a script, the way you do with unblu (you include unblu scripts into your pages) 
This works in both cases only if the user browser allows third party cookie because the URL within the iframe includes the URL of the desired page (unblu/Facebook, etc.), and since  the iframes domain is another domain than yours.

If you use unblu UI to initialise a session, unblu automatically checks cookie-support before displaying the UI. So if the browser does not support third party cookie, unblu will display a popup with content/origin from unblu, where the user can start a session.

However, if you use unblu API to initialise a session, you need to implement the following workaround to solve the issue:

  1. first you check whether the browser supports third-party-cookie or not. 
    1. you call an unblu service that sets cookie (https://start.unblu.com/unblu/cookieSupport?action=setCookie), for example like this: 
      1. var url = "https://start.unblu.com/unblu/cookieSupport?action=setCookie";
        ajax.request("GET", url, onSuccess, onFailure, null, {});
    2. store the value provided to you in a variable, for example in "respText"
    3. then you call another unblu service to verify the previous cookie value (https://start.unblu.com/unblu/cookieSupport?action=verifyCookie&cookieValue=respText), for example like below:
      1. var url = "https://start.unblu.com/unblu/cookieSupport?action=verifyCookie&cookieValue=" + respText;
        ajax.request("GET", url, onSuccess, onFailure, null, {});
    4. please remember that you are performing a CORS request, so you need to set "withCredentials: true"
    5. the verification service sends you a "true" if the browser supports third party cookie, otherwise it sends a "false"
  2. in case the browser does not support third party cookie, then you display a popup with an origin from http://customer.unblu.com/your-landing-page-for-the-popup/  Please note that by default Safari blocks popup, thus, it is important that the user is asked to click on a link/button which executes the JS opening the popup. A direct try to open popup without user interaction will be blocked by Safari. So it is important that the user is provided with any element (Button/Image, etc) having a click listener to open popup.
    1. for a proof of concept you can use this URL "http://customers.unblu.com/example/confirm.php" to display the popup, for example like below:
      1. var url = 'http://customers.unblu.com/example/confirm.php';		
        var popup = window.open(url,'1437728504397','width=790,height=350,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=400,top=220');
    2. if you need a custom popup, please get in touch with our support-and-service team through our support portal https://support.unblu.com
  3. the user needs to confirm that we (unblu) can set cookie into his browser, once this is done.
  4. the popup gets closed and the user should reload the page.
  5. in this way, unblu can set cookie and, as a result, an unblu session can be initialised through API successfully.
  6. a simple example can be found here: http://test.aufdeinerseite.com/cookie-support/

How can we help?

Chat with us and we will take you through our site!

Read about how we use cookies and how you can control them by clicking "Cookie Settings." If you continue to use this site, you consent to our use of cookies.