I have an AWS "Classic Load Balancer" that relays the traffic and for 3 EC2 instances. On these EC2 instances (it's simple Linux machines) I have a GlassFish 4.1 running and listening to port 80.

When calling the URL for a single server, everything is fine (works as it is supposed to) but when the traffic is relayed by the Load Balancer, the request to the application server has no cookies.

I checked the balancer's "Enable load balancer generated cookie stickiness" option and also tried "Enable application generated cookie stickiness". Both times the balancer chooses a target server for the first request and uses relays all subsequent requests to the same server - but omits the cookies.

For example
After the login I have these cookies:

AWSELB      DD17B9....
JSESSIONID  8f22ce....
mnzkks      1869:1000:34....

When I click on any link on the page, I see that my browser includes the new cookies in the request:

GET /mypage/detail HTTP/1.1
Host: my.page.com
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 OPR/45.0.2552.888
Referer: https://my.page.com/dashboard
Cookie: JSESSIONID=8f22ce ...;
        AWSELB= DD17B9....; 

In a filter of my application I print out all the cookie names and check for the "mnzkks". If I can't find any cookie it prints no cookie :)

When using the server's original URL it prints


When using the URL of the balancer it always prints no cookie, even though the browser includes all 3 cookies in the request

who ate my cookies?

  • I did a bit of searching to see if I could help answer this, but I can't find any documentation. Since no-one here can answer perhaps you should try the AWS forums? If you work it out please answer your own question, it's interesting and could help others. – Tim Jul 4 '17 at 19:24
  • Does your Set-Cookie response have a trailing semicolon? If so, these AWS docs suggest that that may be one of the issues: "If you have a trailing semicolon in the Set-Cookie field of an application cookie, the load balancer ignores the cookie." – Castaglia Jul 14 '17 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.