123456789101112131415161718192021222324252627 |
- namespace AipGateway.API.Utils
- {
- public static class CookieHelper
- {
- public static void SetCookie(this HttpContext context, string key, string value, double minutes)
- {
- context.Response.Cookies.Append(key, value, new CookieOptions
- {
- Expires = DateTime.Now.AddMinutes(minutes)
- });
- }
- public static void DeleteCookie(this HttpContext context, string key)
- {
- context.Response.Cookies.Delete(key);
- }
- public static string GetCookie(this HttpContext context, string key)
- {
- context.Request.Cookies.TryGetValue(key, out string value);
- if (string.IsNullOrEmpty(value))
- value = string.Empty;
- return value;
- }
- }
- }
|