Restrict Duplicate login

Posted by Dotnetfundakumar under ASP.NET AJAX on 8/31/2009 | Views : 3738 | Status : [Member] | Replies : 9
How to Restrict Duplicate login
For Ex: i am open Ie window i am login this username:Test:pwd:123 ->login sucessfully.
again another Ie window open same username and password give i am try to login how to
restrict login here how to intimate login doesnot exists. how will do this

i need .aspx and .vb source code

Regards
Kumar



Responses

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Dotnetfundakumar

That is an Interested Question and a little bit simple to answer. Now you can add a Field to your Database name "Status"

Now the Field status will be in the Login table, now when the User Logs into that Field and if the Field the a Value of "0" then Update that Field and make it "1" . This will tell you if there is a user who is logged in or not. and when the User logout or click the Close button catch that and update the Table accordingly. Now that means that field will have a Default of "0" when you create a login and when the user tries to login for the first time there must be a Stored procedure that will update the record and set it to "1" and when someone tries somewhere to use the login, then the System should check if the value is Zero , if its not then it should display a message that says

"This login name is Currently logged in , in another location"

if you want us to go to the code step by step you are welcome.

Thank you for posting at Dotnetfunda

Vuyiswa maseko

Thank you for posting at Dotnetfunda
[Administrator]

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dotnetfundakumar on: 8/31/2009 [Member] Starter

Up
0
Down
My dear Friend
thanks ur reply

I need how to handled session or viewstate or cache



Regards
Kumar

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Dotnetfundakumar

Here is how we declare a Session

Session["My_Session"] = 1;



and you can retrieve the session value from any page within your application like this

int new_Value = Convert.Toint32(Session["My_Session"]);



Thank you for posting at dotnetfunda

Vuyiswa Maseko



Thank you for posting at Dotnetfunda
[Administrator]

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 8/31/2009 [Member] [Moderator] Silver

Up
0
Down
using seesion, ViewState or Cache you can check on the same session means duplicate login for same system. if you want to restrict duplicate login from any machine then you need to maintain the status in the Database.

Other wise add a check on login page that if Session["YourKey"]!=null then redirect to your postlogin page.

Thanks & Regards
Lakhan Pal Garg

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
That is Good Lakhangarg

but your last statement

Other wise add a check on login page that if Session["YourKey"]!=null then redirect to your postlogin page.


will not correct the duplicate logins. Because if the user is in a different machine then session will fail you. This can only be controled in the database as you said in your first paragraph.

Lakhangarg keep up the good work , you are doing well for dotnetfunda

Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 8/31/2009 [Member] [Moderator] Silver

Up
0
Down
Thats what i have mentioned Vuyiswamb..

if the user will be on the same machine only then he/she can use state variable like session other wise database approach needs to be used we can't use session in that case..

Thanks & Regards
Lakhan Pal Garg
http://lakhangarg.blogspot.com/


Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsrinivas on: 8/31/2009 [Member] Starter

Up
0
Down

hi
i have one doubt, after login due to some problems(power failure or some ....) the system has shut down then what wil happen the status will be 1 in database. so it should not allow the next logins.

thanks

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 8/31/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
That is a Good Question.

As i remember one of my early days of Development , this led me to Create an Administration Tool to monitor that Situation. and creating that was just a piece of cake, because you would only set the field to 0 again.

Now tell me , Do you have another way that you can suggest ?

Thank you for posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 8/31/2009 [Member] [Moderator] Silver

Up
0
Down
Hi-

i Think Vuyiswamb is right.. in this case we have only one option reset the value from admin panel.. or we can create a Page to Reset the value by user itslef.. but that can also lead to duplicate login.. :)

Dotnetfundakumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response