创建
Session["Username"] = User.Text.Trim();
使用
if(Session["Username"] == "")
{}cookie你查一下书就知道了
 

解决方案 »

  1.   

    creat it
       Session["ID"]=UserId.Text.Trim();
    on the other page
    if ((Session["ID"]!=null)
    {
    string strVar=Session["ID"].ToString();
    }
    搜索Session
      

  2.   

    session使用
    Session["a"] = obj;创建
    if (Session["a"]!=null)
      objType yourObj=(objType)Session["a"];使用
      

  3.   

    Response.Cookies.Add(new HttpCookie("LastVisit", DateTime.Now.ToString()));
      

  4.   

    1.Session 对象变量只针对单一网页使用者,也就是说各个联机的机器有各自的Session 对象变量,不同的联机无法互相存取。也就是当网页使用者关掉浏览器或超过设定Session 变量对象的有效时间时,Session 对象变量就会消失。
    语法:
    Session("变量名")="内容"
    首先:
    Session("Id")=txtID.Text
    Session("IsPassed")="True"-----------
    引用时:
    If Session("IsPassed")=Nothing Or Session("IsPassed")<>"True" Then
    Response.Redirect("Test.aspx")
    End If2.Cookies、Session 和Application 对象很类似,也是一种集合对象,都是用来在保存数据。但Cookies 和其它对象最大的不同是Cookies 将数据存放于客户端的磁盘上,Application 以及Session 对象是将数据存放于Server 端.
    语法如下:
    Response.Cookies(Name As String).Value="资料".
    例如:先定义:
    Response.Cookies("Cookie1").Value="Microsoft VisualStudio .Net"
    再引用:
    For shtI=0 To Request.Cookies.Count-1
    Response.Write("变量名称:" & Request.Cookies.Item(shtI).Name & _
    "<br>变量内容:" & Request.Cookies.Get(shtI).Value &
    "<br>")
    Next
    Response.Cookies.Clear()
    End Sub
      

  5.   

    Response.Cookies["OA"]["username"]=txtUsername.Text;
    System.Text.Encoding theEncoding = System.Text.Encoding.GetEncoding("gb2312");
    //解决中文问题
    string cookieValue = Request.Cookies["OA"]["username"].ToString();
    string StrUserName = HttpUtility.UrlDecode( cookieValue,theEncoding );