June 2002
Intermediate to advanced
816 pages
28h 12m
English
Remove
Session.Remove(ByVal name As String)
Removes an item from the Session collection by name.
name
A String argument containing the name (key) of the item to remove.
The example determines whether the item with the key “foo” exists in the Session collection and if it does, removes the item and displays an appropriate message:
Sub Page_Load( )
If Not Session("foo") Is Nothing Then
Session.Remove("foo")
Message.Text = "Item 'foo' was removed."
Else
Message.Text = "Item 'foo' does not exist."
End If
End SubThe Remove method is provided for backward compatibility with classic ASP. In classic ASP, this method was accessed through the Contents collection. In ASP.NET, this method can be accessed either directly, as shown above, or through the Contents collection.
Read now
Unlock full access