Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing Public Variables from Global.asax

Reply
Thread Tools

Accessing Public Variables from Global.asax

 
 
Ekul
Guest
Posts: n/a
 
      01-30-2004
I have an application that allows users to login and logout. I track how
many users are logged in and when each individual is logged in. The
application will not allow concurrent logins(let a user log in twice at the
same time). My problem is I am having trouble telling when the user is
logged off. If they click the logout button everything works fine. But if
the close the browser by clicking the x or navigate to another url through
the address bar I will get no indication that they have logged off. To
remedy that I placed the code to logoff the user in the Session_End method
of the Global.asax page. But there is a problem with this as well. I need
the user ID to perform the logoff tasks. I can't get this from a session
object because by the time the Session_End method is reached the session
object I previously created is destroyed. I tried using a public variable to
hold the user ID but I can not get access to it in the global.asax. I also
tried to place the user ID in a public shared variable, but this causes the
user ID to be overwritten whenever a new user logs in. Is there any way to
create a public variable that I can access from the global.asax page that is
not shared among application instances? Should I be looking at this from
another angle? Any ideas or help would be greatly appreciated.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9lIEFnc3Rlcg==?=
Guest
Posts: n/a
 
      01-30-2004
I would create a hashtable (aka Dictionary) in application scope that tracks logins and last accessed timestamps. I would create a helper class that manages synchronizing your hashtable with objects in session. Each time Session_End is called I'd look at the hashtable and remove any old records. I'd also remove the record if the user clicks "logout". And of course, if a entry is found in the hashtable don't let the user log in. Each hashtable entry would store the login as a key and timestamp as the item

Joe Agste
www.geekyfrog.com
 
Reply With Quote
 
 
 
 
Ekul
Guest
Posts: n/a
 
      01-30-2004

Joe,

I tried something similar to this before. The only problem was that I had
know way of knowing which user was logging of when they hit Session_End.
For example, say two users logon at the same time, userA & userB. Then lets
say that userB's session times out and userA's session is still active. How
would I be able to tell it is userB that I need to logoff and not userA, or
vice versa? There is nothing that identifies who's session timed out.
Please let me know if I misunderstood your advice. Thanks for taking the
time to help!

Luke

"Joe Agster" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I would create a hashtable (aka Dictionary) in application scope that

tracks logins and last accessed timestamps. I would create a helper class
that manages synchronizing your hashtable with objects in session. Each time
Session_End is called I'd look at the hashtable and remove any old records.
I'd also remove the record if the user clicks "logout". And of course, if a
entry is found in the hashtable don't let the user log in. Each hashtable
entry would store the login as a key and timestamp as the item.
>
> Joe Agster
> www.geekyfrog.com



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSD 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments