I've created a login webpage that sends a userId and password to a Java servlet via javascript. When the servlet validates the credentials, it sends a response to the webpage, and I store the userName in sessionStorage by using:
sessionStorage.userId=uName; //read uName from servlet & save userId for this session
After this, I navigate to a new page by using window.location.replace("home.html")
, and in home, I read userId
for further use.
I'm using Apache Tomcat v8.0 on Windows.
I'm running my login page on the browser via:
localhost:8080/login.html
10.11.12.13:8080/login.html
(from my machine's IP, given inipconfig
)
The setup works fine in Chrome and Firefox for both localhost and IP.
However, in IE11, sessionStorage works correctly only when I use localhost:8080. When I supply the IP address, sessionStorage.userId
doesn't retain its value.
Since IE is working fine for localhost, I know that Window.sessionStorage is supported by IE.
I've also tried saving the userId in a separate .js file, but that value is lost as soon as the page navigates.
Any suggestion would be earnestly welcomed. Thanks