.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);
    }

  }
}

 

上一篇:redis 分布式缓存session 方式登录


下一篇:1.0AuthenticationHttpContextExtensions--HttpContext 扩展函数【IAuthenticationService】