How to prevent a user from having multiple instances of the Same Web application

前端 未结 16 631
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 05:39

I\'m wondering if it is possible to determine if a user already has a web browser open to the web application I\'m working on. It seems that they can open several instances

16条回答
  •  伪装坚强ぢ
    2020-12-06 06:05

    You can do this by window.name. In java script window.name has blank value on each new tab. Set window.name value on login page and save in session.

    window.name = Math.random() + "_YourApplication"
    

    Now check this window.name on master page/Layout page. Log out user if it contain multiple tab.

     if (!window.name || window.name != '@Session["WindowName"]') {
        //Log Off code
     }
    

提交回复
热议问题