How to restrict user to practice only one session in one browser window in mvc

We are developing a web application using MVC4 and jQuery Mobile. Recently, we have discovered one important issue: "The user is using a different account in the same browser" to override the existing browser of the current account. Therefore, we decided not to allow the user to use two different accounts in the same browser. We searched a lot but couldn't find the perfect solution. So we tried the code below loading the login page.

[AllowAnonymous]
        public ActionResult Index()
        {
            if (!Request.IsAuthenticated)
            {
                return View("mLogin");
            }
            else
            {
                return View("UserAlready");

             }
        }

      

We wrote this code in the login controller. The login page will only be displayed if the user is not registered. After it's authenticated, we'll restrict it to load the login page again.

My question.

Is this the correct method? Does it have any flaw? Or is there any other better approach?

+3


source to share


1 answer


Use a session ID cookie. In the Authorize Action Filter, check the cookie for the session value with the custom session value if the two match well and well, otherwise you can take the necessary action.



0


source







All Articles