c# 登录Cookie

登录时存:

  HttpCookie cookieUserPower = new HttpCookie("UserPower");

                    cookieUserPower.Value = loginuser._UserPower.ToString();

                    cookieUserPower.HttpOnly = true;

                    HttpContext.Current.Response.Cookies.Add(cookieUserPower);



页面判断:

 if (Request.Cookies["UserID"] == null)

        {

            ClientScript.RegisterClientScriptBlock(this.GetType(), "sc", "<script>window.location.href='WorkerLogin.aspx';</script>");

        }

        else if (Request.Cookies["lzf"].Value.Trim() == "-1")

        {

            ClientScript.RegisterClientScriptBlock(this.GetType(), "sc", "<script>alert('您还没有通过审核!');window.location.href='WorkerStudy.aspx';</script>");

        }


你可能感兴趣的:(cookie)