判断用户是否登录

 public class Class_LoginJudge
    {
        public static void IsLogin()
     {
      if(Object.Equals(HttpContext.Current.Session["partno"],null) || Object.Equals(HttpContext.Current.Session["name"],null) || Object.Equals(HttpContext.Current.Session["cc_desc"],null) || Object.Equals(HttpContext.Current.Session["bz_desc"],null) ||  Object.Equals(HttpContext.Current.Session["cc_dept"],null))
      {
       HttpContext.Current.Response.Write("<script language=\"javascript\">");
       HttpContext.Current.Response.Write("alert(\"错误提示:你还没有登录!\");");
       HttpContext.Current.Response.Write("parent.location.href=\"../login.asp?act=out\";");
       HttpContext.Current.Response.Write("</script>");
                HttpContext.Current.Response.End();
      }
     }
     public static void OutLogin()
     {
      HttpContext.Current.Session["ad_user_id"]=null;
      HttpContext.Current.Session["ad_user_limit"]=null;
      HttpContext.Current.Session["ad_user_object"]=null;
      HttpContext.Current.Session["safe_code"]=null;
      HttpContext.Current.Session.RemoveAll();
      HttpContext.Current.Session.Clear();
      HttpContext.Current.Response.Redirect("../login.asp");
      HttpContext.Current.Response.End();
        }
    }

posted on 2009-03-10 11:05  Gsun  阅读(606)  评论(0)    收藏  举报

导航