Click here to Skip to main content
15,926,144 members
Home / Discussions / C#
   

C#

 
GeneralRe: Prevent Multiple Login Pin
akosidandan24-Aug-11 2:41
akosidandan24-Aug-11 2:41 
GeneralRe: Prevent Multiple Login Pin
Not Active24-Aug-11 3:21
mentorNot Active24-Aug-11 3:21 
GeneralRe: Prevent Multiple Login Pin
akosidandan24-Aug-11 3:45
akosidandan24-Aug-11 3:45 
AnswerRe: Prevent Multiple Login Pin
BobJanova24-Aug-11 2:25
BobJanova24-Aug-11 2:25 
GeneralRe: Prevent Multiple Login Pin
akosidandan24-Aug-11 3:03
akosidandan24-Aug-11 3:03 
GeneralRe: Prevent Multiple Login Pin
Not Active24-Aug-11 3:18
mentorNot Active24-Aug-11 3:18 
GeneralRe: Prevent Multiple Login Pin
akosidandan24-Aug-11 3:31
akosidandan24-Aug-11 3:31 
GeneralRe: Prevent Multiple Login Pin
BobJanova24-Aug-11 4:13
BobJanova24-Aug-11 4:13 
Well, your first approach should be to make sure your boss realises it's a dumb requirement (though I wouldn't necessarily put it in those words), and if it comes from a client, get your boss to have the same discussion with the person who put it in the specification. By far the best solution here is if you can persuade the customer that they don't actually want this 'feature' at all. Even if you're a newbie or new to the company, don't be intimidated out of at least raising the point.

If you try that and you really can't get it removed, the logic goes something like this (in the login attempt script, once authorisation has been checked and you are about to log in) – pseudocode only, if that wasn't obvious:
string sid = DBQuery("select lastsessionid from user where userid=(ID)", userid);
Session session = GetSession(sid);
if(IsValidSession(session)){
 // Already a non-expired session for this user
 // Close the other session
 session.Logout();
}
thisSession["user"] = userData; // or however you record that this is a logged in session

// record this as the current session for the user
DBQuery("update user set lastsessionid=(sessID) where userid=(ID)", thisSession.ID, userid);


I think it's better to kill any previous sessions rather than reject the login, otherwise it's way too easy to lock yourself out for the session expiry timeout (turn off machine at work without pressing 'Logout' link and go home/to lunch/etc) or, if there is some AJAX that keeps the session alive indefinitely, permanently.

I haven't tried to do this with ASP.net so I'm not sure how easy it is to get hold of session objects for sessions other than the one you're currently in. You need to be able to do that because otherwise you won't be able to tell when a previous session has expired.

session.Logout is a placeholder for clearing whatever you put into the session on login (so the next page load in that session is as a guest). Again, with ASP.net's role management that might be more tricky than it should be.
AnswerRe: Prevent Multiple Login Pin
PIEBALDconsult24-Aug-11 2:58
mvePIEBALDconsult24-Aug-11 2:58 
GeneralRe: Prevent Multiple Login Pin
akosidandan24-Aug-11 3:21
akosidandan24-Aug-11 3:21 
QuestionC#.net working with windows authenication Pin
dcof23-Aug-11 12:14
dcof23-Aug-11 12:14 
AnswerRe: C#.net working with windows authenication Pin
Mycroft Holmes23-Aug-11 15:14
professionalMycroft Holmes23-Aug-11 15:14 
AnswerRe: C#.net working with windows authenication Pin
ake0123-Aug-11 23:29
ake0123-Aug-11 23:29 
AnswerRe: C#.net working with windows authenication Pin
Bernhard Hiller25-Aug-11 5:15
Bernhard Hiller25-Aug-11 5:15 
QuestionC#.net working with active directory Pin
dcof23-Aug-11 12:03
dcof23-Aug-11 12:03 
AnswerRe: C#.net working with active directory Pin
Simon Bang Terkildsen23-Aug-11 12:44
Simon Bang Terkildsen23-Aug-11 12:44 
AnswerRe: C#.net working with active directory Pin
SledgeHammer0123-Aug-11 12:49
SledgeHammer0123-Aug-11 12:49 
Questionhow to put condition under the table which is inside the repeater?? Pin
Dhyanga23-Aug-11 11:14
Dhyanga23-Aug-11 11:14 
SuggestionRe: how to put condition under the table which is inside the repeater?? Pin
Simon Bang Terkildsen23-Aug-11 11:28
Simon Bang Terkildsen23-Aug-11 11:28 
GeneralRe: how to put condition under the table which is inside the repeater?? Pin
Dhyanga23-Aug-11 12:06
Dhyanga23-Aug-11 12:06 
QuestionDatagridview to Excel.....Automate Reporting with Timer Pin
PDTUM23-Aug-11 9:48
PDTUM23-Aug-11 9:48 
AnswerRe: Datagridview to Excel.....Automate Reporting with Timer Pin
Dalek Dave23-Aug-11 11:33
professionalDalek Dave23-Aug-11 11:33 
GeneralRe: Datagridview to Excel.....Automate Reporting with Timer Pin
PDTUM23-Aug-11 12:32
PDTUM23-Aug-11 12:32 
AnswerRe: Datagridview to Excel.....Automate Reporting with Timer Pin
Mycroft Holmes23-Aug-11 15:09
professionalMycroft Holmes23-Aug-11 15:09 
QuestionReading from a ListBox Pin
Wamuti23-Aug-11 5:57
Wamuti23-Aug-11 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.