Skip to content
Related Articles

Related Articles

ASP Session.Contents Collection
  • Last Updated : 03 Mar, 2021

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:

  • Key: It contains a single value i.e Key which represents the name of the items.

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



ASP




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

Example-2: 

ASP




<%
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 
My Personal Notes arrow_drop_up
Recommended Articles
Page :