I am using HAProxy for A/B testing and here is the snippet of my HAProxy configuration
listen http 127.0.0.1:8080
maxconn 18000
use_backend a-version-backend if { req.cook(SITEID) -m beg a_version }
use_backend b-version-backend if { req.cook(SITEID) -m beg b_version }
default_backend ab-test
backend ab-test
balance roundrobin
cookie SITEID insert indirect nocache maxlife 48h
server server1 10.0.0.2:80 weight 25 cookie a_version
server server2 10.0.0.3:80 weight 25 cookie a_version
server server3 10.0.0.4:80 weight 50 cookie b_version
After reading the documentation, I realised that HAProxy can only create session cookie. Is it possible to create a persistent cookie in HAProxy ?
==== UPDATE ====
Sorry for the confusion, what I meant is persistent cookie (updated my question ) https://en.wikipedia.org/wiki/HTTP_cookie#Persistent_cookie
This is the cookie that set by HAProxy. It doesn't have expiry date and browser will treat it as session cookie https://en.wikipedia.org/wiki/HTTP_cookie#Session_cookie
The problem with session cookie is when user close their browser, it will delete the cookie. This is unacceptable for A/B test because they might come back to the website few days later and analytics tracking will treat them as different person.
And this is an example of persistent cookie from Facebook. It has an expiry date.
maxlife 48h
).