Session bug

Session bug

am 25.09.2007 19:51:59 von Lasse Edsvik

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) & "
")
End If
Next

Re: Session bug

am 25.09.2007 21:41:33 von exjxw.hannivoort

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) & "
")
> 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) & "
"
Next

Response.Write "


"

For Each Item in Session.Contents
Session.Contents.Remove(Item)
Response.Write Item & "=" & Session.Contents(Item) & "
"
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) & "
"
Next

Response.Write "
"

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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Session bug

am 25.09.2007 23:59:07 von Dave Anderson

"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.