SameSite Cookie Attribute Handler

SAP Commerce Cloud includes a cookie handler that you can use to configure the SameSite attribute of the Tomcat cookie processor to handle cookies differently depending on their origin.

The cookie handler works for cookies added only through standard Servlet API. It doesn't support headers that are assembled as raw values and sent as String values.

To use this feature, make sure that any Accelerator templates that you're using are generated from SAP Commerce Cloud version 1905 and later.

Configuration

You can enable or disable the SameSite cookie handler with the cookies.SameSite.enabled property in the local.properties or manifest.json file. The default value of cookies.SameSite.enabled is false, but if you install the samlsinglesignon extension, this value changes to true automatically.

Attribute Properties

The handler defines the value of the SameSite cookie attribute using the following four values, listed from most to least important:

  1. cookies.<domain>.<path>.<name>.SameSite
  2. cookies.<domain>.<path>.SameSite
  3. cookies.<domain>.SameSite
  4. cookies.SameSite

The handler first looks for a property that respects all the cookie attributes (domain, path, and name). If the handler doesn't find it, it looks for a property that considers the domain and path attributes. If such a property doesn't exist, the handler considers a property that respects the domain attribute. If the handler doesn't find it, it uses a property with the global default value (cookies.SameSite).

The property uses the following values:

  • Unset
  • None
  • Lax
  • Strict

For definitions of these values, see SameSite cookiesInformation published on non-SAP site.

Troubleshooting

If you notice that the handler has problems with finding a valid property name for a given cookie, set the cookies.samesite logger level to DEBUG to enable debug logging for the handler.