public static void SetAuthenticationTicket(string username, bool persist)
{
if (username == null)
throw new ArgumentNullException(username);
#if ASPNETCORE
var principal = new GenericPrincipal(new GenericIdentity(username), EmptyStringArray);
var httpContext = Dependency.Resolve<IHttpContextAccessor>().HttpContext;
httpContext.Authentication.SignInAsync("CookieAuthenticationScheme", principal).Wait();
#else
HttpCookie authCookie = FormsAuthentication.GetAuthCookie(username, persist);
HttpContext.Current.Response.Cookies.Remove(authCookie.Name);
HttpContext.Current.Response.Cookies.Add(authCookie);
#endif
}