regexapachecookiesmod-headerssamesite

Apache mod_headers regex for multiple cookies?


I'm using the following code to edit set the SameSite attribute for specific cookies:

<IfModule mod_headers.c>
Header always edit Set-Cookie ^(login_session.*)$ $1;SameSite=Strict
Header always edit Set-Cookie ^(different_cookie.*)$ $1;SameSite=Strict
</IfModule>

This works, BUT is there a way to combine the two rules into a one-liner? I know how to set this to ALL cookies or to exclude specific cookies, but is there a way to specifiy 2 or more cookies in a one-line regex? Thanks


Solution

  • This should work.

    <IfModule mod_headers.c>
        Header always edit Set-Cookie ^((login|different)_session.*)$ $1;SameSite=Strict
    </IfModule>