Monday, March 22, 2010

The Timeout property sets or returns the timeout period for the Session object for this application, in minutes

. If the user does not refresh or request a page within the timeout period, the session will end. Syntax Session.Timeout[=nMinutes] Parameter Description nMinutes The number of minutes a session can remain idle before the server terminates it. Default is 20 minutes Examples <% response.write(" ") response.write("Default Timeout is: " & Session.Timeout) response.write(" ") Session.Timeout=30 response.write(" ") response.write("Timeout is now: " & Session.Timeout) response.write(" ") %> Output: Default Timeout is: 20 Timeout is now: 30 Methods: ASP Abandon Method ________________________________________ The Abandon method destroys a user session. Note: When this method is called, the current Session object is not deleted until all of the script on the current page have been processed. This means that it is possible to access session variables on the same page as the call to Abandon, but not from another Web page. Syntax Session.Abandon Examples File1.asp: <% Session("name")="Hege" Session.Abandon Response.Write(Session("name")) %> Output: Hege File2.asp: <% Response.Write(Session("name")) %> Output: (none) ASP Contents.Remove Method ________________________________________ The Contents.Remove method deletes an item from the Contents collection. Syntax Application.Contents.Remove(name|index) Session.Contents.Remove(name|index) Parameter Description name The name of the item to remove index The index of the item to remove ________________________________________ Examples for the Application Object Example 1 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove("test2") for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Application("test1")=("First test") Application("test2")=("Second test") Application("test3")=("Third test") Application.Contents.Remove(2) for each x in Application.Contents Response.Write(x & "=" & Application.Contents(x) & " ") next %> Output: test1=First test test3=Third test Examples for the Session Object Example 1 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove("test2") for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test Example 2 <% Session("test1")=("First test") Session("test2")=("Second test") Session("test3")=("Third test") Session.Contents.Remove(2) for each x in Session.Contents Response.Write(x & "=" & Session.Contents(x) & " ") next %> Output: test1=First test test3=Third test ASP Contents.RemoveAll Method