【问题标题】:Reading cookie from the request through Lua + nginx script通过 Lua + nginx 脚本从请求中读取 cookie
【发布时间】:2017-12-19 07:52:57
【问题描述】:

我试图通过 lua 脚本从 Nginx 层的 HTTP 请求中读取 cookie。但它总是返回一个空值。我不确定我在这里缺少什么。下面是我的代码sn-p

local ck = require "resty.cookie"

local field, err = ck:get("jwt-token") 

“jwt-token”是 cookie 名称,存在于“/”路径中。

【问题讨论】:

    标签: nginx cookies lua


    【解决方案1】:

    这个方法对我有用 lua local token = ngx.var.cookie_MYTOKEN ngx.say(token)

    这是参考

    https://github.com/openresty/lua-nginx-module/issues/19

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-17
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 2017-05-31
      • 2012-05-22
      相关资源
      最近更新 更多