2014年10月16日 星期四

Session

    protected void Button2_Click(object sender, EventArgs e)
    {
        if (Session["age"] != null)
        {
            Response.Write("You are " + Session["age"] + " years old<br/>");
            Response.Write("Session ID: " + Session.SessionID.ToString() + "<br/>");
            Response.Write("Time out: " + Session.Timeout.ToString() + "<br/>");
        }
        else
            Response.Write("Session not exist!");

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
       
        Session["age"] = TextBox1.Text;
       
        Session.Timeout = 1;
    }

沒有留言:

張貼留言