-2

I am trying to make the client receive a page that will set the required cookies after authentication, and then go to another page after setting the cookies.

Client => Server: credentials

Server => Client:

<html>
    <body>
        <script>
            document.cookie="name=myName;path=/;secure;HttpOnly";
            document.cookie="token=abcdefg;path=/;secure;HttpOnly";
            window.location="https://localhost/myPage.html"
        </script>
    </body>
</html>

This fails when HttpOnly is set. How do I fix it?

theAnonymous
  • 1,687
  • 2
  • 24
  • 59

1 Answers1

1

HttpOnly cannot be set (or read) from js - that's why it's called HttpOnly.

So answering your question:

How do I fix it?

You cannot "fix" it - it's by design. But you could set it from the server side.

zerkms
  • 240,587
  • 65
  • 429
  • 525