cookies:

  ashx端赋值:

context.Response.Cookies["Username"].Value = "";

  后台端加载:

Response.Write(Request.Cookies["Username"].value);

 

session:

  ashx端赋值三部:

using System;
using System.Web;
using System.Web.SessionState;//第一步:引用命名空间

//第二步:实现接口
public class Login : IHttpHandler, IRequiresSessionState 
{

    public void ProcessRequest(HttpContext context)
    {
        string un = context.Request["uname"];
        string pwd = context.Request["pwd"];

        string json = "{\"ok\":\"0\"}";

        Users u = new UsersData().Select(un, pwd);
        if (u != null)
        {
            context.Session["user"] = un;//第三步:实现Session赋值
            json = "{\"ok\":\"1\"}";
        }
...

  后台端加载:

Response.Write(Session["user"]);

 

相关文章:

  • 2022-12-23
  • 2021-03-30
  • 2021-12-29
  • 2022-12-23
  • 2021-07-28
  • 2021-10-05
  • 2021-05-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-09-06
  • 2021-12-21
  • 2021-06-28
相关资源
相似解决方案