Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I would like to change all cookies to be secure and http-only. It works fine for one cookie, but doesn't work when multiple cookies are set in response.

Apache mod_header rule should change cookies from:

Set-Cookie cookie1=value; Path=/somePath
Set-Cookie cookie2=value; Path=/somePath


Set-Cookie cookie1=value; Path=/somePath; Secure; Http-Only
Set-Cookie cookie2=value; Path=/somePath; Secure; Http-Only

I use mod_headers for it with following rule:

Header edit Set-Cookie ^(.*)$ $1;Secure;HttpOnly

It works fine when only one cookie is set, but if there is more than one, it just removes all the following and they are not set at all.

Any help how to write mod_headers rule for multiple values? or the problem is in something else?

share|improve this question

2 Answers 2

I found the answer. Problem has been in version of apache installed on server. Edit command is supported from version 2.2.4 but the version has been 2.2.3 (default on RHEL 5+). So I upgreded httpd and everything works fine.

For more about upgrading httpd on RHEL or CentOS see:

share|improve this answer

This rule would work for apache 2.2.3

Header set Set-Cookie HttpOnly;Secure
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.