.netcore使用session

using Fast.NetCore.Web.Extend;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Fast.NetCore.Web.Helper
{
  public static class SessionHelper
  {
    static HttpContext httpContext = ToolHttpContext.Current;
    
    public static void SetSession(string key, string value)
    {
      httpContext.Session.SetString(key, value);
    }

    public static string GetSession(string key)
    {
      return httpContext.Session.GetString(key);
    }


    public static void DeleteSession(string key)
    {
      httpContext.Session.Remove(key);
    }

  }
}

 

posted @ 2021-10-22 16:50  亦承  阅读(125)  评论(0)    收藏  举报