Rich-text Reply

if user clear cookies ,how to keep consistency experience

estelle_qiu 12-15-16
Accepted Solution

if user clear cookies ,how to keep consistency experience

Our test platform is mobile web and mobile app. I find Optimizely variation allocate through cookies and there are two quesitons .

  1. If user login in on web app and be seen as test audience, Optimizely will set cookie in the web .Then users download our app, but in app there not set cookies,  even if we set cookies for them, but how to control variation version ? I try to set optimizelyBuckets ,but it can' t .
  2. The second question is that if user clear cookies ,how to keep consistency experience?
robertchan 12-15-16

Re: if user clear cookies ,how to keep consistency experience

This should get you on the right path. You need to check for cookie existence and take action based on whether or not a cookie exists. So in addition to what I provide below, you might want to create something to read and store one of the existing cookies into your own.


var createCookie = function(name,value,days) {
    if (days) {
        var date = new Date();
        var expires = "; expires="+date.toGMTString();
    else var expires = "";
    document.cookie = name;

var getCookie = function(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for(var i=0; i<ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1);
        if (c.indexOf(name) != -1) return c.substring(name.length,c.length);
    return "";

So you'll have a set of helper functions to help you with cookies, these can be found everywhere online then you'll want to check if a cookie exists, if not, take action:


var presentCookie = getCookie('THECOOKIEYOUNEED')

if(presentCookie !== ''){ //DO SOMETHING IF THE COOKIE'S THERE }
Robert Chan

Experimentation Hero