• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 設定Session 對象變量的有效期限

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    因為每一個和Server 端聯機的客戶端都是獨立的Session,所以Server 端需要額外的資源來管理這些Session。有時候使用者正在瀏覽網頁時,突然去做其它的事情而沒有把網頁的聯機關閉;如果Server 端一直浪費資源在管理這些Session 上,那么勢必會讓 服務器 的效


        因為每一個和Server 端聯機的客戶端都是獨立的Session,所以Server 端需要額外的資源來管理這些Session。有時候使用者正在瀏覽網頁時,突然去做其它的事情而沒有把網頁的聯機關閉;如果Server 端一直浪費資源在管理這些Session 上,那么勢必會讓服務器的效率降低。所以當使用者超過一段時間沒有動作時,我們就可以將Session 釋放。要更改Session 對象的有效期限,只要設定TimeOut 屬性即可;TimeOut 屬性的默認值是20 分鐘。下列范例將Session 對象的TimeOut 屬性設定為一分鐘:

    <Html>
    <Form Runat="Server">
    <Asp:Button Id="Button1" Text="顯示" OnClick="Button1_Click"
    Runat="Server" />
    目前時間:<Asp:Label Id="Label1" Runat="Server" />
    <P>
    第一個Session 的值:<Asp:Label Id="Label2" Runat="Server" /><Br>
    第二個Session 的值:<Asp:Label Id="Label3" Runat="Server" /><Br>
    </Form>
    <Script Language="VB" Runat="Server">
    Sub Page_Load(Sender As Object,e As Eventargs)
    If Not Page.IsPostBack Then
    Session("Session1")="Value1"
    Session("Session2")="Value2"
    Session.Timeout=1
    Label1.Text=Format(Now(),"HH:MM:SS")
    Label2.Text=Session("Session1")
    Label3.Text=Session("Session2")
    End If
    End Sub
    Sub Button1_Click(Sender As Object,e As Eventargs)
    Label1.Text=Format(Now(),"hh:mm:ss")
    Label2.Text=Session("Session1")
    Label3.Text=Session("Session2")
    End Sub
    </Script>
    </Html>



        第一次進入這個網頁時,Session 對象變量的值會被顯示出來;接著我們不要做任何動作靜待一分鐘,一分鐘過后按下Button1 時,Session 對象變量的內容便被釋放:

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>