--- In [email protected], "amonteath"
<[EMAIL PROTECTED]> wrote:
>
> Hi, Happy '05!,
>
> I am trying to remove all but a few selected Session variables
from
> the Session.Contents collection. The code seems to remove a few of
> the session variables but not all that want removed. And it seems
to
> remove some that I do not want removed. What am I doing wrong in
> this code?
>
> Code:
>
>
> 'Release Session Variables******************
>
> For Each Item in Session.Contents
> If Item <> "Start" And Item <> "VisitorID" And Item
> <> "LocationID" And Item <> "NatCoID" And Item <> "DealerID" Then
> Session.Contents.Remove(item)
> End If
> Next
>
> For Each x in Session.Contents
> Response.Write(x & " = " & Session.Contents(x) & "<BR />")
> Next
I thought I would post that I used a work around by setting the
session variables to an empty string rather that trying to remove
the variable.
Summary of code that works for me:
If Session.Contents("NatCo")="True" Then
For Each Item in Session.Contents
If Item <> "Start" Then
If Item <> "VisitorID" Then
Session.Contents(item)=""
End If
End If
Next
End If
The variables are still there, but they are empty.
Thanks,
Alan
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/