Shopify Session Token Implementation - Not working in incognito mode

Hi,

As said by shopify we are migrating our app to Shopify App Bridge using session token authentication. In the browser normal mode everything is working good. But when I try it in the incognito mode, it just runs into a infinite loop ending with an error saying

“This app can’t load due to an issue with browser cookies. Try enabling cookies in your browser, switching to another browser , or contacting the developer to get support.”

Below is the code that I used to detect if this is the first time the shop is loading the app.

Please let me know if I am doing anything wrong here…

// shopify bridge app actions 

var permissionUrl = 'https://'+
                          host+
                          '/admin'+
                          '/oauth/authorize?client_id='+
                          apiKey+
                          '&scope='+scope+'&redirect_uri='+
                          redirectUri;

      if (window.top == window.self) {
        window.location.assign(permissionUrl);      
      }else {
        var app = createApp({
          apiKey: "<%= ShopifyApp.configuration.api_key %>",
          shopOrigin: '<%= "#{ @current_shopify_session.domain }" if @current_shopify_session %>',
          forceRedirect: true
        });
      }