我想在会员发帖的时候把会员名字直接放到Label中
不用会员自己输入,如何从Session或者Cookie里得到会员信息?

解决方案 »

  1.   

    在用户登录的时候,先将用户名放进Session中
    Session["name"]=txtUsername.Text;然后要使用的时候取出来即可
    lblUser.Text=Session["name"];
      

  2.   


            //读取cookie
            public void ShowCookie()
            {
                if (Request.Cookies["worker"]!=null)
                {
                    HttpCookie OneCookie;
                    OneCookie = Request.Cookies["worker"];                TxtName.Text = OneCookie.Values["CardId"].ToString();
                    
               }
            }//读取session
    if(session["CardId"]!=null)
    {
    TxtName.Text =session["CardId"].tostring();
    }
      

  3.   

    cookie:
    在用户登录的时候,先将用户名放进Session中 
    HttpCookie hc = new HttpCookie("name");
    hc.value = txtUsername.Text;
    Response.appendCookie(hc);然后要使用的时候取出来即可 
    Request.Cookies["Name"].value
      

  4.   

    Session["name"]=txtUsername.Text; 
    取的时候用Session["name"]
      

  5.   

                    
                    if (Request.Cookies["userInfo"] != null)
                    {
                         return HttpUtility.UrlDecode(Request.Cookies["userInfo"]["userName"].ToString());
                    }    
      

  6.   

    在用户登录的时候,先将用户名放进Session中 
    Session["name"]=txtUsername.Text; 然后要使用的时候取出来即可 
    lblUser.Text=Session["name"].ToString();
      

  7.   

    System.Web.HttpCookie HC =new HttpCookie("userCode","1");[align=left] Response.AppendCookie(HC);
    System.Web.HttpCookie f = Request.Cookies["userCode"];
        string a= f.Value;
    Response.Write( a);[/align]