Server Load Balancer provides session persistence function. With session persistence enabled, Server Load Balancer can distribute requests from the same client to the same backend server during the session period.

For layer-4 listeners, session persistence is based on the IP address. The listener of Server Load Balancer forwards requests from the same IP address to the same backend server. For layer-7 listeners, session persistence is based on cookies.

If you choose to rewrite the cookie, you must configure the cookie on the backend server. Suppose there are two domain names under your Server Load Balancer service: and If you want to configure session persistence for, you can set the cookie name to name, and set a cookie of which the key is name for on the backend server.

Follow the instructions in this section to set cookies on a backend server.


  1. Open the httpd.conf file and make sure that the following line is not commented.
    LoadModule usertrack_module modules/
  2. Add the following configurations in the VirtualHost file.
     CookieName name
     CookieExpires "1 days"
     CookieStyle Cookie
     CookieTracking on


Configure the cookie as follows.

server {
    listen 8080;
    location / {
      add_header Set-Cookie name=xxxx;
        root html;
        index index.html index.htm;


Configure the cookie as follows.

    server.modules  = ( "mod_setenv" )
    $HTTP["host"] == "" {
          server.document-root = "/var/www/html/"
          setenv.add-response-header = ( "Set-Cookie" => "name=XXXXXX"      }