1

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:

  1. localhost:8080/login.html
  2. 10.11.12.13:8080/login.html (from my machine's IP, given in ipconfig)

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

Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39

2 Answers2

3

I found my answer on: Local website renders differently using (IP address or machine name) vs localhost?

Turns out, that the issue was with my html, not my javascript. I added this line in my head tag:

<meta http-equiv="X-UA-Compatible" content="IE=11">

and that fixed it.

Community
  • 1
  • 1
Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39
1

Don't know if this helps but there was a time where console only was available if you had devtools open which lead to some exceptions and not working code.

Do you use the latest version of ie11?

Maybe this also helps: JavaScript localStorage object broken in IE11 on Windows 7

Community
  • 1
  • 1
Harper04
  • 355
  • 2
  • 10
  • Thank you Harper for your prompt response, but if it was a IE version issue, I suspect it would've reflected when I ran on localhost also. The storage seems to work fine when the html is running via localhost – Saransh Kejriwal Jan 13 '17 at 10:22