I’m new to HAProxy and need some help to configure the cookie expiration date, all information I find online is either from old versions or doesn’t match my configuration. See below my current configuration. Any advise would be appreciated. Thx!
Thank you @AaronWest! Just configured it like that, but the cookie expiration date still shows “1969-12-31T23:59:59.000Z” in Google Chrome. Any thoughts?
In Chrome it shows the date and time as you suggest but it seems to be fine in Firefox… I’m thinking it’s a Chrome bug, I hope only a display one but guess we can test with a short maxlife.
Okay so I’m being stupid… Stupid because I now remember doing this before!!
So let’s clear this one up… You have 2 types of cookie, session cookies and persistent cookies, persistent cookies get written to disk I think while session cookies can live only up to when you close the browser.
HAProxy uses session cookies but it can set the maxlife and maxidle value of these cookies.
When you provide no maxlife or maxidle the “Value” of the cookie will just be “ServerName”, however, when you enable a setting such as maxlife you will see the value change to “ServerName|W/Ndy|W/Ndv”.
The extra characters are the timers added to the cookie which will count down accordingly.
I hope that helps make it clearer and I hope it helps me remember this again for next time too!
No, you are right! In Chrome it shows 1969 in expiration date while “session” in Chrome…but I still don’t understand why I can’t set a specific date or time frame instead of “session”…
To have an expires on date you would need to use a different type of cookie which HAProxy doesn’t do, a persistent cookie.
The reason Chrome shows 1969 is this is just what it does with some session cookies while for me Firefox correctly shows it as type “session”.
The maxlife and maxidle values are being encoded along with the cookie value. Check in your browser with and without the maxlife/maxidle being set, if you have neither the value will just be “ServerName” but if you provide a maxlife it’ll be “ServerName + Encoded time values”.
Here is someone else who had the same confusion we just have: