Session cleaning problem

D

Dan King

At a summary page, I am trying to clean up Session.Contents so the user can
go back to the main page and not retain any unnecessary info.
I have entered this into my summary page, but it seems to only eliminate
every other or every third entry. If I refresh the page about 0 times
everything eventually clears out. Anyone know why it would do this?

I don't want to use Session.Abandon because there are a few Session.Contents
I want to retain, like usernams and passwords.

<%
----snip----
For Each objItem in Session.Contents
Session.Contents.Remove objItem
Next
----snip----
%>

Session.Contents are being added like this:

<%
----snip----
Session("uName") = uName 'put info into a session variable
Session("uEmail") = uEmail 'put info into a session variable
Session("uPass") = uPass 'put info into a session variable
Session("uDomain") = uDomain 'put info into a session variable
----snip----
%>

Thanks
 
D

Dan King

I found my answer.
---------
arrSessionsToKeep = array("uName","uPass","uEmail","uDomain")
strSessionsToDelete = ""
for each objItem in Session.Contents
OkayToDelete = True
for each arrItem in arrSessionsToKeep
if arrItem = objItem Then
OkayToDelete = False
exit for
end if
next
if OkayToDelete then
strSessionsToDelete = strSessionsToDelete & objItem & ","
End If
next
arrSessionsToDelete = Split(strSessionsToDelete, ",")
for each arrItem in arrSessionsToDelete
Session.Contents.remove(CStr(arrItem))
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top