0

I'm need add token to my page to authenticate application in iframe. Problem is, when I set domain to cookie it won't add to page. I create cookie as in wicket example:

  WebResponse webResponse = (WebResponse) RequestCycle.get().getResponse();

  Cookie cookie = new Cookie("MY_AUTH_TOKEN", "token");
  cookie.setPath("/");
  cookie.setDomain("domain_in_iframe.com");

  webResponse.addCookie(cookie);

HTML:

<iframe src="http://domain_in_iframe.com/" style="width:100%; height:500px;">

</iframe>

When setDomain is used cookie is not present in browser. Without using serDomain method cookie is present but shows as cookie with localhost domain.

Even adding cookie by hand in webbrowser works but this code don't. Any ideas why?

Mr Jedi
  • 33,658
  • 8
  • 30
  • 40

1 Answers1

1

You cannot set domain different than the current one for security reasons. See https://stackoverflow.com/a/20090012/497381 for more details.

Community
  • 1
  • 1
martin-g
  • 17,243
  • 2
  • 23
  • 35