asp.net - Allow only a single login session per user -
essentially asking this question here, using asp identity instead of asp.net membership provider, , that, answer of no use me.
figured out how it. on login call this:
var key = user.username; var timeout = new timespan(0, 0, httpcontext.current.session.timeout, 0, 0); httpcontext.current.cache.insert(key, session.sessionid, null, datetime.maxvalue, timeout, cacheitempriority.notremovable, null);
and in global.asax
if (session["username"] != null) { var cachekey = session["username"].tostring(); if ((string) httpcontext.current.cache[cachekey] != session.sessionid) logout(); }
Comments
Post a Comment