Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping track of Session IDs?

Status
Not open for further replies.

RoadRacer

Programmer
Dec 18, 2000
61
US
Is there any way of maybe querying the ASP engine itself somehow to see which ID's are still active that anyone knows about short of keeping track of them yourself? I wonder if there's some sort of function you could call or something that would/could return all active ID's at the moment ... Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Ok, basically, I'm having a hard time keeping track of the users currently online. I am storing the usernames in a variable and removing them as they log off the site. Problem is, if they don't log off using the site and just leave, the session times out and the code in the Session_End is either not executing correctly or I'm not totally aware of the way it handles session variables. Reason being that the same exact code is executed when you execute a session.abandon command as with a timeout. But when they logout using the page, I call on a session.abandon and it removes them from the list when the timeout does not (same code, different circumstances)

Anyhow, my idea was that if I can find out which sessions are currently active in the engine when a new session is established, I can 'clean' the list at that moment of any non-existing sessions and have a correct online list at that moment. Don't know if it's possible to pull the id's from the engine tho. =(

Or maybe, you know of a better way to keep track of people online besides using the Session_End event to clean them off the list when they timeout.

Thanks in advance for taking the time to help me out. Ed (RoadRacer) Holguin

"I Hate Computers!"
 
I am not real sure how you could code it. But try taking each session id and checking it's value. I am not at a PC that I could work with ASP so I can't try anything myself.

if it's value is null or "" then remove it from your variable or your table whatever you are putting it into.

Walter III

Walt III
SAElukewl@netscape.net
 
I see what you mean, that would work beautifully! Gathering the ID's is not a problem, I can drop them into the same array that I'm storing the usernames into.

But how do I check the value of the ID? I just ran through the Wrox books I have and I can't find a way to do it. It's probably in there and maybe I'm just breezing right by it... Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Nope, no luck. Haven't been able to find a way to check active ID's. *sob* Ed (RoadRacer) Holguin

"I Hate Computers!"
 
Yeah, I've tried this James, but for some reason, the OnEnd event doesnt' seem to be executing when the user timeout his connection. I have a logout page where I execute a Session.Abandon command and then that calls the OnEnd event and everything works as advertised! But if my user just lets it timeout ... his name lingers on the list. =(

So obviously, the code works because when I force an end, it removes them ... but I'm going crazy trying to figure out how to remove them on timeout. *nervous breakdown pending* Ed (RoadRacer) Holguin

"I Hate Computers!"
 
RoadRacer,

This is an excerpt from the MSDN documentation on the IIS Session object.

Session_OnEnd
The Session_OnEnd event occurs when a session is abandoned or times out.

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top