Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / December 2005

Tip: Looking for answers? Try searching our database.

multiple logins using cache

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
seal - 26 Oct 2005 17:44 GMT
I have a question regarding keeping a username in the cache in order to
prevent multiple logins. I read 'Preventing Multiple Logins in ASP.NET' by
Peter Bormberg (great article
http://www.eggheadcafe.com/articles/20030418.asp) and everything works fine,
however, I think we are going to have problems from our users having to wait
for their cache to clear out before they can login again. Is there a way to
clear the username out of the cache when they logout? I seem to be missing
something here.

In my logout:
       System.Web.Security.FormsAuthentication.SignOut()

       Dim i As Integer
       For i = Session.Count - 1 To 0 Step -1
           Session.Remove(Session.Keys(i))
       Next

       Session.Remove("user")
       Session.Abandon()
Does not work.

When I go back to login, it is still finding the 'user' in the cache
item.?.? Can I not remove this item from the cache? What do I not understand
here?
seal - 26 Oct 2005 18:09 GMT
Ok, it seems as though I got ahead of myself.

This code added to my logout procedure allows me log out and back on.
       Dim _sKey As String
       _sKey = Session.Item("user")

       If Not _sKey = "" Then
           HttpContext.Current.Cache.Remove(_sKey)
       End If
Now, how can I handle the user who refuses to use the logout button? If they
just close their browser, I assume there is nothing that can be done except
wait for the cache to expire. Will we be able to release this user somehow in
IIS for those users who will call and complain?

> I have a question regarding keeping a username in the cache in order to
> prevent multiple logins. I read 'Preventing Multiple Logins in ASP.NET' by
[quoted text clipped - 20 lines]
> item.?.? Can I not remove this item from the cache? What do I not understand
> here?
darrenterrell - 02 Dec 2005 23:39 GMT
The only solution that I can think of to solve this problem is to create
a function that will call the server via AJAX to sign out the user.  You
can call this function in the unload event for the web page.  If you use
master pages or some similar implementation, then this will not be too
difficult to do (since you will need this on every page in the web site
- besides the login page).  I have used a similar implementation for
this in the past and it worked well.  However, I would still recommend
keeping the server side timeout in place.  Things like sudden power
outages will kill the session w/o firing the unload event.  Let me know
if you need help w/ any of the code.

> *Ok, it seems as though I got ahead of myself.
>
[quoted text clipped - 46 lines]
> understand
> > here? *



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.