using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Fast.NetCore.Web.Helper
{
public static class CookieHelper
{
public static void SetCookies(this HttpContext httpContext,string key,string value,int minutes=30)
{
httpContext.Response.Cookies.Append(key, value, new CookieOptions
{
Expires = DateTime.Now.AddMinutes(minutes)
});
}
public static void DeleteCookie(this HttpContext httpContext,string key)
{
httpContext.Response.Cookies.Delete(key);
}
public static string GetCookieValue(this HttpContext httpContext,string key)
{
httpContext.Request.Cookies.TryGetValue(key, out string value);
return value;
}
}
}