Session bug

Hello

I have a problem with running classic asp on a windows 2003 server. For some
reason it doesnt remove the sessions. I reload page and it removes some,
reload again and it removes a few more, very odd...

Any ideas? :S im clueless


For each key In Session.Contents()

If instr(key, "Question") >0 Then
Session.Contents.Remove(key)
Response.Write(key & ":" & Session(key) & "<br>")
End If
Next
Lasse Edsvik [ Di, 25 September 2007 19:51 ] [ ID #1828867 ]

Re: Session bug

Lasse Edsvik wrote on 25 sep 2007 in
microsoft.public.inetserver.asp.general:

> Hello
>
> I have a problem with running classic asp on a windows 2003 server.
> For some reason it doesnt remove the sessions. I reload page and it
> removes some, reload again and it removes a few more, very odd...
>
> Any ideas? :S im clueless
>
>
> For each key In Session.Contents()
>
> If instr(key, "Question") >0 Then
> Session.Contents.Remove(key)
> Response.Write(key & ":" & Session(key) & "<br>")
> End If
> Next


When you remove a session variable, the position changes and
"For each key In" will skip those positions and:

try and see what happens when you repeatedly press F5 on this asp file:

<%
Session("one") = 1
Session("two") = 2
Session("three") = 3
Session("Zone") = 1
Session("Ztwo") = 2
Session("Zthree") = 3

For Each Item in Session.Contents
Response.Write Item & "=" & Session.Contents(Item) & "<BR>"
Next

Response.Write "<hr>"

For Each Item in Session.Contents
Session.Contents.Remove(Item)
Response.Write Item & "=" & Session.Contents(Item) & "<BR>"
Next
%>

So better do this:

<%
Session("one") = 1
Session("two") = 2
Session("three") = 3
Session("Zone") = 1
Session("Ztwo") = 2
Session("Zthree") = 3

For Each Item in Session.Contents
Response.Write Item & "=" & Session.Contents(Item) & "<BR>"
Next

Response.Write "<hr>"

Session.Contents.RemoveAll()
For Each Item in Session.Contents
Response.Write Item & "=" & Session.Contents(Item) & "<BR>"
Next
%>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
exjxw.hannivoort [ Di, 25 September 2007 21:41 ] [ ID #1828869 ]

Re: Session bug

"Lasse Edsvik"
> I have a problem with running classic asp on a windows 2003 server. For
> some reason it doesnt remove the sessions. I reload page and it removes
> some, reload again and it removes a few more, very odd...

If you want to "remove the sessions", why not use Session.Abandon()?

http://msdn2.microsoft.com/en-us/library/ms524319.aspx


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Dave Anderson [ Di, 25 September 2007 23:59 ] [ ID #1828871 ]
Webserver » microsoft.public.inetserver.asp.general » Session bug

Vorheriges Thema: How to Handle Many Page Links in a Search?
Nächstes Thema: Cannot pass session variable