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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -