nginx设置cookie

实例

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

遍历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
                ';
    原文作者:codecraft
    原文地址: https://segmentfault.com/a/1190000007914136
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞