Insert cookie attributes to ADC generated cookies
-
Load balancing cookie persistence
-
Load balancing group cookie persistence
-
GSLB site persistence
-
Content switching cookie persistence
-
LiteralADCCookieAttribute: Append other cookie attributes to the ADC generated cookie, as a string.
-
ComputedADCCookieAttribute: Use an ADC ns variable to conditionally append cookie attributes to the ADC generated cookie, based on the client or server attributes, for example, user agent version.
Use case: Configure SameSite cookie attribute
-
None: Indicates the browser to use a cookie in cross-site context only on secure connections.
-
Lax: Indicates the browser to use a cookie for requests in the same-site context. In the cross-site context, only safe HTTP methods like GET request can use the cookie.
-
Strict: Use the cookie only in the same-site context.
-
Versions of Chrome from Chrome 51 to Chrome 66 (inclusive on both ends)
-
Versions of UC browser on Android earlier to version 12.13.2
Configure ADC generated cookies
-
Create a load balancing virtual server
-
Set the ADC Cookie attributes for the load balancing virtual server, either through LB parameters or LB profile.
-
If you use an LB profile, set the LB profile to a load balancing virtual server.
-
If you choose to use the Computed ADC Cookie Attribute, configure the related rewrite policy.
-
Setting the ADC cookie attributes in load balancing parameters
-
Setting the ADC cookie attributes in the load balancing profile
Setting the ADC cookie attributes in the load balancing parameters by using the CLI
set lb parameter -LiteralADCCookieAttribute <string>
set lb parameter -LiteralADCCookieAttribute SameSite=None
set lb parameter -ComputedADCCookieAttribute <ns variable>
add ns variable cookieattribute_var -type "text(100)" -scope transaction
set lb parameter -ComputedADCCookieAttributE "$cookieattribute_var"
add ns assignment samesiteassign -variable "$cookieattribute_var" -set "\"SameSite=None\""
add policy expression pol_iphone "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"iP\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/OS \\d+\\_/).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).EQ(12).typecast_text_t ALT \"false\").eq(\"true\"))"
add policy expression pol_chrome "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"Chrom\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/Chrom.*\\d+./).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).BETWEEN(51,66).typecast_text_t ALT \"false\").eq(\"true\"))"
add rewrite policy exception_samesite_attribute "pol_iphone || pol_chrome " NOREWRITE
add rewrite policy append_samesite_attribute true samesiteassign
bind rewrite global exception_samesite_attribute 90 110 -type RES_OVERRIDE
bind rewrite global append_samesite_attribute 100 110 -type RES_OVERRIDE
Configure variables by using the GUI
-
Navigate to AppExpert > Variables, and click Add.
-
In the Create Variable page, select Scope as Transaction and Type as text from the drop-down menu.

-
Enter other details, and click Create.
Create an assignment by using the GUI
-
Navigate to AppExpert > Assignments, and click Add.
-
In the Create Assignment page, enter the details, and click Create.
Setting the ADC cookie attributes in load balancing parameters by using the GUI
-
Navigate to Traffic Management > Load Balancing > Change Load Balancing parameters.

-
In the Configure Load Balancing Parameters pane, enter appropriate values for either one of the fields based on your requirement:
-
Literal ADC Cookie Attribute
-
Computed ADC Cookie Attribute

-
-
Click OK.
Setting the ADC cookie attributes in the load balancing profile by using the CLI
add lb profile <profile name> -LiteralADCCookieAttribute <string>
add lb profile LB-Vserver-Profile-1 -LiteralADCCookieAttribute SameSite=None
add lb vserver LB-VServer-1 SSL 10.102.148.37 443 -persistenceType COOKIEINSERT -lbprofilename LB-Vserver-Profile-1
add lb profile <profile name> -ComputedADCCookieAttribute <ns variable>
add ns variable cookieattribute_var -type "text(100)" -scope transaction
add ns assignment samesiteassign -variable "$cookieattribute_var" -set "\"SameSite=None\""
add lb profile LB-Vserver-Profile-1 -ComputedADCCookieAttributE "$cookieattribute_var"
add policy expression pol_iphone "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"iP\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/OS \\d+\\_/).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).EQ(12).typecast_text_t ALT \"false\").eq(\"true\"))"
add policy expression pol_chrome "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"Chrom\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/Chrom.*\\d+./).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).BETWEEN(51,66).typecast_text_t ALT \"false\").eq(\"true\"))"
add rewrite policy exception_samesite_attribute "pol_iphone || pol_chrome " NOREWRITE
add rewrite policy append_samesite_attribute true samesiteassign
add lb vserver LB-VServer-1 SSL 10.102.148.37 443 -persistenceType COOKIEINSERT -lbprofilename LB-Vserver-Profile-1
bind lb vserver LB-VServer-1 -policyName exception_samesite_attribute -priority 90 -gotoPriorityExpression 110 -type RESPONSE
bind lb vserver LB-VServer-1 -policyName append_samesite_attribute -priority 100 -gotoPriorityExpression 110 -type RESPONSE
Setting the ADC Cookie attributes in the load balancing profile by using the GUI
-
Navigate to Traffic Management > Load Balancing > Virtual servers.
-
Select a virtual server and click Edit.
-
Under Advanced Settings section, click Add profiles.

-
In the Profiles section, click Add to create an LB Profile.If you have already created a profile, choose it from the LB Profile drop-down menu.

-
In the LB Profile pane, enter appropriate values for either one of the fields based on your requirement:
-
Literal ADC Cookie Attribute
-
Computed ADC Cookie Attribute

-
Click OK.
-
Set the created LB profile to the LB virtual server created in Step 1.
Verify ns variable configuration
| Warning message | Reasons |
|---|---|
| NS Variable is not configured. Configure it with type text() and scope transaction for variable | NS variable is not yet configured. |
| Scope of configured NS variable is not transaction. | Variable is configured but scope is not set to “transaction.” |
| Type of variable is not Text(). | Variable is configured but type is not set to “Text”. |
| Configured value-max-size for the NS Variable is greater than 255. | The value configured for the NS variable is greater than 255 characters. Note: A maximum length of 255 characters can be appended to an ADC generated cookie. The characters that exceed the maximum length are truncated. |
Sample output
set lb parameter -ComputedADCCookieAttribute "$lbvar"
Warning: NS Variable is not configured. Please configure it with type text() and scope transaction
Done
show lb parameter command.
show lb parameter
Global LB parameters:
Persistence Cookie HttpOnly Flag: ENABLED
Use Encrypted Persistence Cookie: DISABLED
Use Port For Hash LB: YES
Prefer direct route: YES
Retain Service State: OFF
Start RR Factor: 0
Skip Maxclient for Monitoring: DISABLED
Monitor Connection Close: FIN
Use consolidated stats for LeastConnection: YES
Allow mac mode based vserver to pick thereturn traffic from services: DISABLED
Allow bound service removal: ENABLED
TTL for Domain Based Server: 0 secs
NetScaler Cookie Variable Name: $lbvar(NS Variable is not configured. Please configure it with type text() and scope transaction)
Done
Sample configuration for inserting cookie attributes in GSLB deployment
-
Set the ADC cookie attributes in the LB profile (LB-Vserver-Profile-1).
-
Set the Literal ADC Cookie Attribute value, for example “SameSite=None", in the LB profile.
-
Set the LB profile to the load balancing virtual server (LB-VServer-1), which represents the GSLB service.
add gslb vserver GSLB-VServer-1 SSL -backupLBMethod ROUNDROBIN -tolerance 0 -appflowLog DISABLED
add gslb site site1 10.102.148.4 -publicIP 10.102.148.4
add gslb service site1_gsvc1 10.102.148.35 SSL 443 -publicIP 10.102.148.35 -publicPort 443 -maxClient 0 -siteName site1 -sitePersistence HTTPRedirect -sitePrefix ss1 -cltTimeout 180 -svrTimeout 360 -downStateFlush ENABLED
bind gslb vserver GSLB-VServer-1 -serviceName site1_gsvc1
bind gslb vserver GSLB-VServer-1 -domainName www.gslb.com -TTL 5
add service service-1 10.102.84.140 SSL 443
add lb profile LB-Vserver-Profile-1 -LiteralADCCookieAttribute SameSite=None
add lb vserver LB-VServer-1 SSL 10.102.148.37 443 -persistenceType COOKIEINSERT -lbprofilename LB-Vserver-Profile-1
bind lb vserver LB-VServer-1 service-1
Sample configuration for inserting cookie attribute in content switching deployment
-
Set the ADC cookie attributes in the LB parameters.Note:You can set the ADC cookie attributes in the LB profile as well.
-
Configure the ns variable (cookieattribute_var) of Type set to Text and Scope set to Transaction.
-
Set the Computed ADC Cookie Attribute in the global LB parameters using the ns variable.
-
Set the rewrite policies (exception_samesite_attribute and append_samesite_attribute) to the content switching virtual servers for inserting the cookie attributes.
add ns variable cookieattribute_var -type "text(100)" -scope transaction
set lb parameter -ComputedADCCookieAttributE "$cookieattribute_var"
add ns assignment samesiteassign -variable "$cookieattribute_var" -set "\"SameSite=None\""
add policy expression pol_iphone "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"iP\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/OS \\d+\\_/).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).EQ(12).typecast_text_t ALT \"false\").eq(\"true\"))"
add policy expression pol_chrome "(HTTP.REQ.HEADER(\"User-Agent\").CONTAINS(\"Chrom\") && (HTTP.REQ.HEADER(\"User-Agent\").REGEX_SELECT(re/Chrom.*\\d+./).REGEX_SELECT(re/\\d+/).TYPECAST_NUM_T(DECIMAL).BETWEEN(51,66).typecast_text_t ALT \"false\").eq(\"true\"))"
add rewrite policy exception_samesite_attribute "pol_iphone || pol_chrome " NOREWRITE
add rewrite policy append_samesite_attribute true samesiteassign
add lb vserver LB-VServer-1 SSL 10.102.148.35 443
add lb vserver LB-VServer-2 SSL 10.102.148.36 443
add cs vserver CS-VServer-1 SSL 10.102.148.42 443 -persistenceType COOKIEINSERT
add cs action act1 -targetLBVserver v1
add cs action act2 -targetLBVserver v2
add cs policy CS-policy-1 -rule "HTTP.REQ.URL.CONTAINS(\"file1.html\")" -action act1
add cs policy CS-policy-2 -rule "HTTP.REQ.URL.CONTAINS(\"file2.html\")" -action act2
bind cs vserver CS-VServer-1 -policyName CS-policy-1 -priority 1
bind cs vserver CS-VServer-1 -policyName CS-policy-2 -priority 2
bind cs vserver -policyname exception_samesite_attribute 90 110 -type RES_OVERRIDE
bind cs vserver -policyname append_samesite_attribute 100 110 -type RES_OVERRIDE