1

I want to trigger a script in my we application while the same link is launched from another tab.

Eg : I have live session of www.myweb.com in tab1 and i'm launching the same link www.myweb.com in tab2, At that time i need to deactivate (Signoff) the session in tab1.

Karthikeyan
  • 406
  • 3
  • 14

1 Answers1

1

You can't expect to do this from the server side. The server doesn't know what tab/window/frame a request comes from. It isn't aware if requests are being sent from one window, or many. As far as the server is concerned, all of the requests are part of the same session, because the browser remembers which cookie it is supposed to use for that URL space.

I've taken a quick look at the spec, and didn't see any mention of cookie options that can change this behavior.

So you'll need to do this from the client side. As the first step of your page's script, you should try deleting the session cookie, and then make an ajax request to the server. Hopefully, what will happen is the server will assign the client a new cookie. Of course, I have a sneaking suspicion that any previously-opened tabs/windows to the same site will pick up on the new session cookie.

Deleting cookies is covered in javascript - delete cookie

Community
  • 1
  • 1
slashingweapon
  • 11,007
  • 4
  • 31
  • 50