9951 explained code solutions for 126 technologies


nginx-luaGet cookie with Lua


server {
  location / {
    content_by_lua_block {
      local val = ngx.var.cookie_somecookie
      ngx.say(val)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.var.cookie_

access specified cookie value (comes as a part of variable name)

cookie_somecookie

will return somecookie cookie value

ngx.say

output given text to client