AB testing cookie infinite duration/maxlife


#1

Howdy !

I have some ab test behind some haproxies ( in kubernetes ).

I’d like to store SERVERID into session so that someone that does not clear his/her cookies always gets redirected to the same version of the website. ( i.e.: give it a duration of 365 days )

The doc says The cookie will only be a session cookie and will not be stored on the client's disk..
But there is also a maxlife that I think will have Haproxy store that cookie ? Right ?

But apparently a cookie can only have a maximum maxlife of 24h.

Would there be a way to have the client store a long lived cookie ? Or to hack it ?

I can also do pull requests if need be :slight_smile:

Thanks !

PS: for the moment I might set up a service that will set a long lived SERVERID when it sees one.

Edit:
I tried this approach : cookie SERVERID insert maxlife 24h and this only gives me a session cookie, so assumptions were wrong.


#2

Correct, as far as I can see haproxy currently only does session cookies, not persistence cookies. You could have the backend emit a persistence SERVERID cookie in “insert preserve” mode.

Someone hacked this on the browser side with JS (but I’m not a big fan of doing this in the browser):

Should you choose to write a patch, you can find details in the CONTRIBUTING file. Patches are reviewed on the mailing list.