A
few days back I faced a problem which made me go back and forth a couple of
times over the code which I had written, and my work process was virtually
ceased. The problem was regarding user login, i.e. “How can I be able to
prevent concurrent user login using the same credentials from different
machines”
Well,
as I have found the solution I would like to share it with you all.
If we are using Membership Providers to store the user credentials, then we can use the IsOnline property of MemebershipUser Class to check if it’s a concurrent login or not. If the user logins with a username and password, then it is checked that the user is online or not, if he / she is not online(that means there is no concurrent login) then he / she is allowed, otherwise the user is redirected to another page.
If we are using Membership Providers to store the user credentials, then we can use the IsOnline property of MemebershipUser Class to check if it’s a concurrent login or not. If the user logins with a username and password, then it is checked that the user is online or not, if he / she is not online(that means there is no concurrent login) then he / she is allowed, otherwise the user is redirected to another page.
Add this code to the LoggedIn() event of the Login control, which
is raised after the user is authenticated
or in you Login Button click.
protected void logctrlLoginPage_LoggingIn(object sender, EventArgs
e)
{
MembershipUser
GetUser = Membership.GetUser(User.Identity.Name,
false);
if
(GetUser.IsOnline)
{
Response.RedirectPermanent("~/NotAllowed.aspx");
}
}
And make changes to the Membership tag in web.config as this,
<membership defaultProvider="AspNetSQlMembershipProvider" userIsOnlineTimeWindow="1">
A user is considered online if the current date and time minus the UserIsOnlineTimeWindow property value is earlier than the LastActivityDate for the user. The LastActivityDate for a user is updated to the current date and time by the CreateUser, UpdateUser and ValidateUser methods, and can be updated by some of the overloads of the GetUser method.
I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done.
ReplyDeletefull stack developer training in chennai
I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
ReplyDeleteangular js training in chennai
angular js training in tambaram
full stack training in chennai
full stack training in tambaram
php training in chennai
php training in tambaram
photoshop training in chennai
photoshop training in tambaram
I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
ReplyDeleteoracle training in chennai
oracle training in omr
oracle dba training in chennai
oracle dba training in omr
ccna training in chennai
ccna training in omr
seo training in chennai
seo training in omr
Learn Oracle PLSQL for making your career towards a sky-high with Infycle Technologies. Infycle Technologies is the top Oracle PLSQL Training Institute in Chennai, offering programs in Oracle such as Oracle PL/SQL, Oracle DBA, etc., in the 200% hands-on practical training with professional specialists in the field. In addition to that, the interviews will be arranged for the candidates, so that, they can set their career without any struggle. Of all that, 100% placement assurance will be given here. To have the best career, call 7502633633 to Infycle Technologies and grab a free demo to know more.
ReplyDeletehttps://infycletechnologies.com/oracle-plsql-training-in-chennai
very information article.thanks for sharing.Angular training in Chennai
ReplyDeletekartal beko klima servisi
ReplyDeletekadıköy samsung klima servisi
maltepe mitsubishi klima servisi
pendik bosch klima servisi
üsküdar beko klima servisi
ataşehir alarko carrier klima servisi
çekmeköy daikin klima servisi
ümraniye mitsubishi klima servisi
beykoz vestel klima servisi
Good content. You write beautiful things.
ReplyDeletehacklink
vbet
korsan taksi
mrbahis
mrbahis
sportsbet
vbet
taksi
sportsbet
This post is on your page i will follow your new content.
ReplyDeletesportsbet
casino siteleri
sportsbet giriş
sportsbet
mrbahis
casino siteleri
sportsbetgiris.net
mrbahis.co
mrbahis giriş
amasya
ReplyDeleteantakya
edirne
elazığ
kayseri
DDZZX
Sultanahmet
ReplyDeleteGüneşli
Nişantaşı
Florya
Tüyap
Bahçeşehir
Bakırköy
QWSQW18652
شركة مكافحة حشرات بالقطيف
ReplyDeleteمكافحة حشرات
GetUser.IsOnline is true even after log out.
ReplyDeleteشركة صيانة وتنظيف افران
ReplyDeleteصيانة وتنظيف افران
شركة فك وتركيب باركيه
ReplyDeleteفك وتركيب باركيه
This comment has been removed by the author.
ReplyDeleteYour solution for preventing concurrent user logins is both straightforward and effective. It's clear you've found a practical approach to tackle this common challenge. Also, it's interesting to see the mention of Cambridge Infotech, a reputable software training institute in Bangalore. Thanks for sharing your solution with us!
ReplyDeleteSoftware Training Institute in Bangalore
شركة تنظيف مساجد بالجبيل
ReplyDelete64DmXVLGD5O