apache如何动态使用"Header set Set-Cookie expires = <date>"

Dav*_*idG 11 apache cookies mod-rewrite mod-headers

我使用apache作为负载均衡器和反向代理.对于会话粘性,我正在创建一个包含节点路径的cookie.

Header set Set-Cookie "h=.%{BALANCER_WORKER_ROUTE}e; path=/; domain=.domain.com" env=BALANCER_ROUTE_CHANGED
Run Code Online (Sandbox Code Playgroud)

如何expires将cookie中的值设置为从请求进入后X分钟?

mod_headers的文档甚至Set-Cookie没有详细介绍,因此没有动态语法的信息expires.

我尝试设置max-age但不幸的是max-age不适用于IE 11,我们的很多客户都使用它.

mod_rewrite cookie的文档确实涵盖了如何在cookie中设置生命周期,所以我可以使用这个丑陋的mod_rewrite hack来使用它,但我必须为每个路由做一个规则,因为它在我的<Proxy balancer://my_cluster>部分中不起作用:

RewriteCond %{HTTP_COOKIE} h=.1 [NC]
RewriteRule . -  [CO=h:.1:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.2 [NC]
RewriteRule . -  [CO=h:.2:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.3 [NC]
RewriteRule . -  [CO=h:.3:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.4 [NC]
RewriteRule . -  [CO=h:.4:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.5 [NC]
RewriteRule . -  [CO=h:.5:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.6 [NC]
RewriteRule . -  [CO=h:.6:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.7 [NC]
RewriteRule . -  [CO=h:.7:.domain.com:30:/]
RewriteCond %{HTTP_COOKIE} h=.8 [NC]
RewriteRule . -  [CO=h:.8:.domain.com:30:/]
Run Code Online (Sandbox Code Playgroud)

有关如何完成的任何想法Header set Set-Cookie?谢谢!

Jus*_*man 3

也许你可以用通用规则来保留你的想法

RewriteCond %{HTTP_COOKIE} h=\.([1-8]) [NC]
RewriteRule . - [CO=h:.%1:.domain.com:30:/]
Run Code Online (Sandbox Code Playgroud)