openresty 获取 设置 cookie

创建日期: 2024-07-01 15:01 | 作者: 风波 | 浏览次数: 38 | 分类: openresty

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

local cookie_value = ngx.var.cookie_Foo

或者

local cookie_name = "UID2"
local var_name = "cookie_" .. cookie_name
local cookie_value = ngx.var[var_name]
ngx.header['Set-Cookie'] = 'Foo=abc; path=/'
ngx.header["Set-Cookie"] = { cookie1, cookie2, cookie3 }
local expires = 3600 * 24  -- 1 day
ngx.header["Set-Cookie"] = "session=blah; Path=/; Expires=" .. ngx.cookie_time(ngx.time() + expires)
38 浏览
13 爬虫
0 评论