Name

Clear

Synopsis

Session.
                     Clear( )

Clears the contents of the Session collection for the current user.

Parameters

None

Example

The example clears the contents of the Session collection and writes a message to the Text property of the Message label control that includes the current count of the collection, which should be 0:

Sub Page_Load(  )
   Session.Clear(  )
   Message.Text = "There are " & Session.Count & _
      " items in the Session collection."
End Sub

Notes

The Clear method, which is new for ASP.NET, clears only the contents of the Session collection itself. It does not clear the contents of the StaticObjects collection.

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.