大网数据广告活动
服务器运维问答

Header always edit Set-Cookie not working

· 52CE 我爱测

I am using Apache 2.4.6 on an up-to-date installation of CentOS 7.9. I have tried all variations of setting a header like below (adding/removing quotes, changing the regular expression, etc.) but the Set-Cookie header is never mo…

问题原文

原帖链接 · Michael H · CC BY-SA 4.0

I am using Apache 2.4.6 on an up-to-date installation of CentOS 7.9. I have tried all variations of setting a header like below (adding/removing quotes, changing the regular expression, etc.) but the Set-Cookie header is never modified when sent to the user. Every article I find trying to accomplish this says it works but it just does not work for me.

Header always set TestBefore 1
Header always edit Set-Cookie ^(.*)$ "$1; SameSite=Strict; Secure"
Header always set TestAfter 1

Both the before and after headers are sent but the Set-Cookie header is never modified. Any idea what the issue could be?

已采纳解答

原帖链接 · Andrew Schulman · CC BY-SA 4.0

Your Set-Cookie header is being set in the onsuccess condition, not the always condition. Those are different sets. You need

Header onsuccess edit Set-Cookie (.*) "$1; SameSite=Strict; Secure"

Or just leave out onsuccess, since it's the default. See Header.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。