Archive for category Java

Restricting multiple sessions in IE7

This blog helps you by providing some thoughts on how to manage HTTP session and restrict multiple users logging into your web application using IE 7 browser tab features. Let me brief little bit about the background of the problem and few possible solutions.

Lets assume your web application is currently able to restrict same user logging in multiple times from a particular machine using IE 6 like browser. This means that if user1 has logged in IE6 browser 1, then user1 will not be able to login in IE6 browser2. In this scenario, browser1 HTTP session is different from browser2 session and we will be easily able to restrict the user1.

Our goal is to restrict the user1 logging in multiple times in browser like IE 7 which provides tab features (multiple tabs in same browser). IE7 Browser shares the same session across tabs and this would be our key to restrict user as follows.

Step1: Get all active sessions from your singleton class

MySingleton  mysin= MySingleton.getSessions();   which returns hashmap of all your current sessions. userid is the key and the session as the value.

Step2: loop through all your sessions and compare the current session with the list.

Enumeration e1 = sing.keys();

while (e1.hasMoreElements())


String enumUser = (String) e1.nextElement();

HttpSession enumSess = (HttpSession)sing.get(enumUser );

if(enumSess == session)


//Matching session found which means that another user is alreading using this browser to your web application

//Keep count of sessions




//somewhere down the line, your logic to block the user if count>1


1 Comment