private static void SetCookie(IActionResult result, string token, string value, string path, DateTime expirationDate) { string formattedExpirationDate = $"{expirationDate.ToString("ddd, dd MMM yyy HH:mm:ss", new CultureInfo("En-en"))} GMT"; StringBuilder cookieContent = new StringBuilder(); cookieContent.Append($"{token}={value}; "); if (string.IsNullOrWhiteSpace(path)) { cookieContent.Append("Path=/; "); } else { cookieContent.Append($"Path={path}; "); } cookieContent.Append($"Expires={formattedExpirationDate}"); result.AddHeaderEntry("Set-Cookie", cookieContent.ToString()); }