9951 explained code solutions for 126 technologies


nginx-luaSet cookie with Lua


server {
  location / {
    content_by_lua_block {
      ngx.header['Set-Cookie'] = 'somecookie=abc; path=/'
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

ngx.header

allows to set response headers

Set-Cookie

we'll set this header to send new cookie to client

somecookie

cookie name

abc

cookie value

path=/

cookie path and other options