Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 16, 2013 05:17 PM by Xequence
Member
61 Points
212 Posts
Feb 13, 2013 04:58 PM|LINK
Is it possible to know how many concurrent times a user has logged in? We are developing a web application in which we want to limit the number of concurrent times a user is able to login.
Regards.
Participant
942 Points
198 Posts
Feb 14, 2013 02:52 AM|LINK
use Application state..
http://www.c-sharpcorner.com/UploadFile/freelance91/ASPNETstatemanagementtechniques01012007212655PM/ASPNETstatemanagementtechniques.aspx
http://en.csharp-online.net/ASP.NET_State_Management%E2%80%94Application_State
All-Star
44410 Points
7196 Posts
MVP
Feb 15, 2013 12:17 PM|LINK
Hello,
You can do something like this. Call the below code when the user log in
int maxLimit = 5; if (Membership.GetUser("Username here").IsOnline) { if (Application["Username here"] == null) Application["Username here"] = 0; else { int times = int.Parse(Application["Username here"].ToString()); Application["Username here"] = times++; } } if (int.Parse(Application["Username here"].ToString()) == maxLimit) { //cancel the login }
And when the user logs out, decrease the Application variable value by 1.
Please 'Mark as Answer' if this post helps you.
Contributor
4508 Points
1578 Posts
Feb 16, 2013 05:17 PM|LINK
sounds like an ntier application. abstract it out into a small database/table/csv/txt and post your data.
JORGEMAL
Member
61 Points
212 Posts
Detecting how many concurrent times a user has logged in
Feb 13, 2013 04:58 PM|LINK
Is it possible to know how many concurrent times a user has logged in? We are developing a web application in which we want to limit the number of concurrent times a user is able to login.
Regards.
aaa_78600
Participant
942 Points
198 Posts
Re: Detecting how many concurrent times a user has logged in
Feb 14, 2013 02:52 AM|LINK
use Application state..
http://www.c-sharpcorner.com/UploadFile/freelance91/ASPNETstatemanagementtechniques01012007212655PM/ASPNETstatemanagementtechniques.aspx
http://en.csharp-online.net/ASP.NET_State_Management%E2%80%94Application_State
Ruchira
All-Star
44410 Points
7196 Posts
MVP
Re: Detecting how many concurrent times a user has logged in
Feb 15, 2013 12:17 PM|LINK
Hello,
You can do something like this. Call the below code when the user log in
int maxLimit = 5; if (Membership.GetUser("Username here").IsOnline) { if (Application["Username here"] == null) Application["Username here"] = 0; else { int times = int.Parse(Application["Username here"].ToString()); Application["Username here"] = times++; } } if (int.Parse(Application["Username here"].ToString()) == maxLimit) { //cancel the login }And when the user logs out, decrease the Application variable value by 1.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.Xequence
Contributor
4508 Points
1578 Posts
Re: Detecting how many concurrent times a user has logged in
Feb 16, 2013 05:17 PM|LINK
sounds like an ntier application. abstract it out into a small database/table/csv/txt and post your data.
Credentials