0

With reference my previous question I would like to indicate that the cookies are actually getting sent to the server. Problem is that request.getCookies() always return null no matter what. I can only retrieve them as a String from the request header like this

String cookiesFromHeaderStr = request.getHeader("cookie");

I don't want to read them from the header because I will have to parse the string manually.

I am setting the cookie using Javascript as follows

document.cookie = "loc={\"lng\":0.111111,\"lat\":50.111111}, expires=Wed, 05 Oct 2016 16:22:11 GMT, path=/\""

Is there an obvious reason why the cookies won't actually be returned with request.getCookies()?

Community
  • 1
  • 1
Alexander
  • 335
  • 1
  • 4
  • 12

1 Answers1

0

It's not secure to set cookies from javascript.

I suggest you to create a filter which will set the cookies.

Read this discussion Setting cookie from doFilter method

Community
  • 1
  • 1
Petar Petrov
  • 586
  • 2
  • 10
  • 28