Nginx set cookie

  nginx

Example

ngx.header["Set-Cookie"] = {
        "userId=" .. userId .. "; Max-Age=7200 ; Path=/; HttpOnly",
        "orgId=" .. orgId .. "; Max-Age=7200 ; Path=/; HttpOnly"
    }

Traversal cookie

 header_filter_by_lua '
                    local cookies = ngx.header.set_cookie
                    if cookies then
                        if type(cookies) == "table" then
                            for k,v in pairs(cookies) do
                                ngx.log(ngx.INFO,"k:"..k..",value:"..v)
                            end
                        else
                            ngx.log(ngx.INFO,"cookie:"..cookies)    
                        end
                    end
                ';