public async Task <HttpCookie> CreateLoginCookieAsync(int userID, string token, bool rememberMe) { var cookieViewModel = new CookieLoginViewModel { userID = userID, Token = token, RememberMe = rememberMe }; var cookie = new HttpCookie("null"); var cookieType = await _context.CookieTypes.FirstOrDefaultAsync(x => x.Index == 100); var data = script.Serialize(cookieViewModel); var expiration = rememberMe ? DateTimeOffset.Now.AddDays(14) : DateTimeOffset.Now.AddDays(1); var pullModel = await _service.CreateCookieDataInstanceAsync(data, expiration, cookieType, _context); if (pullModel.ID > 0) { cookie = CreateCookie("login", expiration, pullModel); } return(cookie); }