• Post Reply Bookmark Topic Watch Topic
  • New Topic

Session creation on click of new menu Tab  RSS feed

 
bprakashq bprakashs
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have an application where on the login page i have 6 to 10 sub menus where the user can go into the menu use the functionality based on the requirement.

Here I am facing an issue the scenario follows as:
Let us assume when I login I get the Home Page with sub menus like
a)Change Password
b)Update Information
c)Create new User etc.
Suppose I select change password and right click and open in new Tab then it is sharing the same session which is similar of Home Page.
Now i would like to implement in such a way that when ever i try to do above task i need to go to Login page.

Is it possible to do this way

Could you please let me know your suggestions.

Thanks for your quick response.


Regards,
bprakash
[ December 24, 2008: Message edited by: bprakashq bprakashs ]
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you are talking about a web application, since you appear to be talking about opening new tabs in a browser and talking about Session management between tabs, which is a typical question for web apps. If so then this has nothing to do with Threads.

The short answer is no, there is no way to detect if the page is opened in a new tab or the old tab. All the tabs in a given browser will normally share the same process space, so they would share the same cookies and therefore the same session (though this is very much a client-side behavior so no guarantee that it will be the same for all cases). The best solution is to make your web application not need to care if the page is in a new tab or old tab.

The longer answer is that you can use a random request parameter attached to all your URLs as a token (and stored in the user's session) to identify the newest tab to be displayed. Each request generate a new token, add it to all the URLs for a given page. When a new page is requested compare the token from the request parameter with the one in the user's session. If they are equal then let the user continue, if not then force the user to log in again. At this point if the user opens a link in a new tab then the page loads properly in the new tab but the old tab won't work anymore. Also note that if you force the user to log in again and create a new server-side session then the session for both tabs would end.

So you can kind of simulate what you want, but it is a lot of work and fragile. You are better off writing your web app. so it doesn't matter how many tabs are present.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"bprakashq bprakashs" welcome to Javaranch
please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!