void CheckSession(string origin, string tenantUid)
        {
            HttpCookie usernameCookie  = Request.Cookies["username"];
            HttpCookie tokenCookie     = Request.Cookies["token"];
            HttpCookie lastLoginCookie = Request.Cookies["lastLogin"];

            if (usernameCookie != null)
            {
                LoginSession.LoggedIn = true;
                LoginSession.Username = usernameCookie.Value;
                string sa = @"""" + lastLoginCookie?.Value + @"""";
                LoginSession.LastLogin = lastLoginCookie != null?JsonConvert.DeserializeObject <DateTime>(sa) : DateTime.UtcNow;

                if (tokenCookie != null)
                {
                    LoginSession.Token    = tokenCookie.Value;
                    LoginSession.Username = LoginSession.DecodedJwtToken.Username;
                }

                //LoginSession.Token = Request.Cookies["token"] != null ? Request.Cookies["token"].Value : string.Empty;
            }
            else
            {
                LoginSession.Logout();
            }

            var api = new TotalCodeApiService();

            if (LoginSession.LastLogin > DateTime.MinValue && LoginSession.LastLogin < DateTime.UtcNow)
            {
                LoginSession.LoggedIn = true;
            }
            else if (LoginSession.LastLogin == DateTime.UtcNow)
            {
                var refresh = (LoginResponseContent)api.RefreshToken(tenantUid, origin, LoginSession.Token);
                LoginSession.LoggedIn  = true;
                LoginSession.Token     = refresh.Token;
                LoginSession.LastLogin = refresh.LastLogin.Value;
            }
            else if (LoginSession.LastLogin > DateTime.UtcNow)
            {
                LoginSession.Logout();
            }

            if (LoginSession.LoggedIn)
            {
                //if (LoginSession.CustomerSummary == null)
                //{
                LoginSession.CustomerSummary = api.GetCustomerSummary(tenantUid, origin, LoginSession.DecodedJwtToken);
                if (!LoginSession.CustomerSummary.Balance.IsLiveBalance)
                {
                    LoginSession.Logout();
                }
                //}
            }

            if (!LoginSession.IsMobileBrowser.HasValue)
            {
                LoginSession.IsMobileBrowser = ContentHelper.BrowserIsMobile();
            }
        }