 |
Classic ASP Components Discussions specific to components in ASP 3. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

November 19th, 2004, 11:15 AM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ASP Session End
Hi.
I've created a chat using ASP. All data, I store in global.asa Application. But I've a problem with Sessions.
If somebody close the page with chat and he didn't use logout page (which contains Session and Application name delete function), the Session is not ended. And it won't be for years  ...
Session.Timeout I set to 15 minutes, but it was the same. I tried it with no Session.Timeout setting (naturally it's 20 minutes, I think) with no effect.
I really don't know how to do it. I heard about Response.IsClientConnected. It's possible to do it with this function?
Thanks a lot.
P.S.: Sorry for my english
Ondra "xergic" Kandera
( www.kandera.net )
|

November 22nd, 2004, 03:44 PM
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
hello firend,
try with Session.Abandon. this is what i normally use for ending a session
regards
joseph
|

November 22nd, 2004, 03:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What makes you think the session is not ended??
If your session timeout is 20 minutes, the session will end exactly 20 minutes after the last pages was requested.
Are you maybe redirecting or something like that in Session_OnEnd? This won't work, maybe making you belive that Session_OnEnd doesn't work....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Magic Johnson by Red Hot Chili Peppers (Track 4 from the album: Mother's Milk) What's This?
|

November 22nd, 2004, 04:15 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for answers.
I have some functions in global.asa in Session_onEnd block.
But it doesn't work.
As I said, if somebody close the page without logging out, his nick (recognized by Sessions) is still there. For example:
Somebody logs in for example as "sb". His nick is activated by session. The names are stored in global.asa Application.
But if his browser crashes down, his session is not ended.
Session.Abandon I can't use in this case. But I have created some script, that deletes the nick from Application but session is still on for years.
Thanks for your time and help.
Bye
Ondra "xergic" Kandera
( www.kandera.net )
|

November 22nd, 2004, 04:25 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you show us the code for the Session_OnEnd method?
There are times when Session_OnEnd doesn't fire, but usually it should.
It *does not* fire directly when the user closes her browser. However, it does fire when the session times out, usually after 20 minutes.
If the session was there "for years", you'd soon be running out of memory on your server. So, the session is ended, but probably something else is going wrong....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The Power Of Equality by Red Hot Chili Peppers (Track 1 from the album: Blood Sugar ************ Magik) What's This?
|

November 22nd, 2004, 04:32 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar, you're so kind helping me :)
Here's the source of Session_onEnd:
Code:
Sub Session_onEnd
Application("OnLine") = Application("OnLine")-1
If Session("name") <> "" Then
Application.Lock
Application("user") = Replace(Application("user"), Session("name") & "§", "")
Application("txt20") = Application("txt19")
Application("txt19") = Application("txt18")
Application("txt18") = Application("txt17")
Application("txt17") = Application("txt16")
Application("txt16") = Application("txt15")
Application("txt15") = Application("txt14")
Application("txt14") = Application("txt13")
Application("txt13") = Application("txt12")
Application("txt12") = Application("txt11")
Application("txt11") = Application("txt10")
Application("txt10") = Application("txt9")
Application("txt9") = Application("txt8")
Application("txt8") = Application("txt7")
Application("txt7") = Application("txt6")
Application("txt6") = Application("txt5")
Application("txt5") = Application("txt4")
Application("txt4") = Application("txt3")
Application("txt3") = Application("txt2")
Application("txt2") = Application("txt1")
Application("txt1") = "<span style=""color: #cccccc; font-size: 10px;"">"&now&": Uživatel " & Session("name") & " byl odstranìn kvùli neaktivitì</span>"
Application.Unlock
End If
End Sub
It's in Czech so don't mind that
Thousands thanks
Ondra "xergic" Kandera
( www.kandera.net )
|

November 22nd, 2004, 04:41 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Does your user counter work?
To find out, try this:
1. Make a page that displays the number of users
2. Browse to that page
3. Use a few browser windows ( fresh instances, don't use Ctrl+N) to increase the counter. Make sure you increase it by at least 5 or so.
4. Wait 20 minutes until the sessions have timed out.
5. Browse to the page again.
If the number has decreased again, your Session_OnEnd works, as the number has been decreased in Session_OnEnd
Do any of the application or session variables contain arrays?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: I Could Have Lied by Red Hot Chili Peppers (Track 6 from the album: Blood Sugar ************ Magik) What's This?
|

November 23rd, 2004, 11:10 AM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I didn't try user counter, but I've a user list (Application("user") as array)
But I'll try that.
Thanks
Ondra "xergic" Kandera
( www.kandera.net )
|

November 23rd, 2004, 12:11 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Right. That explains a lot. You cannot access an array in application state directly. You'll need to "materialize" it to a local array first, then reassign it to the app var:
Dim myLocalArray
' Get array from app var
myLocalArray = Application("YourArray")
' Do whatever you need to do with myLocalArray here
' And reassign the array
Application("YourArray") = myLocalArray
HtH,
Imar
|

November 23rd, 2004, 12:54 PM
|
Registered User
|
|
Join Date: Nov 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK, in user list I have almost the same code (only names of variables ar different).
Maybe I should change all the code :D
But thanks for help.
Ondra "xergic" Kandera
( www.kandera.net )
|
|
 |