首页 > 解决方案 > 无法在 nginx 中设置多个 cookie

问题描述

我正在尝试在 NGINX 中设置多个 cookie,但没有合适的解决方案。任何人都可以帮我解决这个问题。我的代码如下:

if ($query_string ~ ([^&]*)cookie=([^&^:]*)){ add_header Set-Cookie "cookieName=test; Domain=.test.com; Max-Age=31536000;path=/"; }

如果请求 url 具有查询参数,则应设置此 cookie cookie=somevalue

标签: nginx

解决方案


if ($arg_cookie = somevalue){
    add_header Set-Cookie "name=value;max-age=3153600000;path=/";
}

推荐阅读