Ivan
Ivan

Reputation: 1314

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

Upvotes: 0

Views: 526

Answers (1)

Wei Zhang
Wei Zhang

Reputation: 24

This should work.

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

Upvotes: 1

Related Questions