nginx获取请求头中的cookie值

时间:2022-12-29 13:45:39

server中添加

1.获取JSESSIONID

set $JSESSIONID_TOKEN "";
if ($http_cookie ~* "JSESSIONID=([\w-]+?)(?=;|$)") {
      set $JSESSIONID_TOKEN "$1";
}

 

2.获取其它KEY值名称的cookie值

set $MUSIC_CHN_CK "";
if ($http_cookie ~* "MUSIC_CHN=(.+?)(?=;|$)") {
      set $MUSIC_CHN_CK "$1";
}