简体   繁体   中英

How to prevent passing HTML5 local storage data between two or more different applications which were deployed at the same container?

i have a big deal with user session monitoring. I need to kill session after closing last application tab or after browser closing.

So, this work was performed. I have developed small library for working with local storage and session storage and i developed mechanism for monitoring of opened browser tabs.

Just simple object with tab counter.

{
    "session_instance_count" : 0
}

And simple methods for writing this object to localstorage:

SessionMonitor.prototype.writeValueByKeyToLS = function (key, value){
   var own = this;
   own.getLocalStorageInstance().setItem(key, value);
};

SessionMonitor.prototype.getLocalStorageInstance = function () {
    return 'localStorage' in window && window['localStorage'];
};

But after deploying another application to Tomcat i have found serious troubles with local storage. All stored values from first application were available in second application.

I stored some data on http://localhost:8080/app1 this data will be available on http://localhost:8080/app2

App1 sending request to open App2 with some parameters

Note: I do not have access to modify source code of second application.

This is my question:

How to prevent passing HTML5 local storage data between two or more different applications which were deployed at the same container?

Solution with local storage was removed, because it's not provide possibilities for set data separately between applications inside one container with same domain pattern. I have checked solution with port configuring inside tomcat/conf/server.xml So we can set different ports to all deployed application. Or we can register one more port for applications

    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
    <Connector port="8086" protocol="HTTP/1.1"
       connectionTimeout="20000"
       redirectPort="8444" />

http://localhost:8080/app2 with http://localhost:8086/app1

Local storages will be unique. But i can't use this solution, because customer don't want this.

I found one more solution: relation between server side and client side.

Just generating unique window.name and storing it inside server session. I hope, that it will be helpfull for somebody.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM