Open In App

ASP Session.Contents Collection

The ASP Session.Contents Collection is used for collecting the items which are appended to the Application object by using script command.  This Collection can also be used to provide a list of items that have been given session scope,  

We can use the Contents.Remove and Contents.RemoveAll methods to remove some or all of the items from the collection.   



Syntax:

Session.Contents(Key) 

Parameter Values:



Example-1: We used to add names and objects that would be added to the contents collections.




<%
Session("name")="Hege"
Set Session("objtest")=Server.CreateObject("ADODB.Connection")
%>

Example-2: 




<%
Session("Name")="Akku"
Session("Favourite Gane")="Cricket"
  
for each x in Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br>")
next
%>

Output:

Name = Akku 
Favourite Game = Cricket 
Article Tags :