Last post Sep 06, 2011 05:03 AM by Mamba Dai - MSFT
Sep 02, 2011 03:51 PM|JimBoHanna1616|LINK
I have about 50 session objects that I would like to clear/set to nothing.
1. How can I get the name of my session object?
2. How can I cycle through them at once?
I think a For/Next will work fine, I am not sure of the syntax of the session object.
I know I have 50 session objects. I refer to them by a name in my code, though I found out that I can also refer to them by index number, but that doesnt give me the name of the object just the value.
This is what I had in mind......but i know it doesnt work as written.
I would also like to know the name of the session object:
For i = 0 to Session.count
Sep 02, 2011 03:56 PM|vishabedre|LINK
Sep 02, 2011 04:01 PM|JimBoHanna1616|LINK
Is there a way to cycle through them 1 at a time?
Session.Abondon will be good for my LogOut Procedure. Which I dont use at this point...but i need too.
I am also looking to add something at login that will set certain session objects to false. I was hoping to be able to get the name based on the index number, but I dont see how i can.
Sep 02, 2011 04:10 PM|JimBoHanna1616|LINK
Also are there different levels of Session Objects? I know there are Application objects...I have about 15 Session objects that store User information (Name, Login, etc) Then each webpage might have 3-5 objects. Those 3-5 are usually used on another page
as well. Like Session("SaveMode") i use that on most of my pages. Though Id like to clear it when the user leaves the page.
So i guess either I figure out what session objects I use on each page and do a cleanup function as part of Page_Unload Or is there some other type of variable I could use that is retained on postbacks?
Personally, I think doing a cleanup would be easier to implement.
Sep 02, 2011 04:13 PM|JimBoHanna1616|LINK
Actually, Page_unload wouldnt work because that gets fired everytime. I would need some event that is fired when changing pages....?
Sep 05, 2011 05:55 AM|Sudeshchandra|LINK
foreach(string name in Session.Contents)
//name - gives you the session name
//Session[name] - gives you the content
//use "Session[name] = null" to clear the contents
Sep 06, 2011 05:03 AM|Mamba Dai - MSFT|LINK
Please check this thread I have solved: