How to extract some value from cookie in nginx

后端 未结 3 1826
一向
一向 2021-02-02 06:28

I am new to Nginx and hope to get some help.

I want to extract certain data (certain fields set by my PHP scripts) from browser cookie in nginx so that I can log it. If

3条回答
  •  北海茫月
    2021-02-02 07:03

    If anyone is using the previous answer with several different cookies in the response the correct regex is:

    map $http_cookie $auth_header {
        default "";
        "~*OAuth.AccessToken=(?[^;]+)" "Bearer $token";
      }
    

    or more general usage:

    map $http_cookie $auth_header {
        default "";
        "~*yourCookieName=(?[^;]+)" "the value you wanna set $variable";
      }
    

提交回复
热议问题