Nginx

Nginx Openresty Get/Set Cookies using LUA.

To set cookies using lua while using nginx_lua module in openresty/nginx server, use this code:

local expires = 3600 * 24  — 1 day
ngx.header[“Set-Cookie”] = “session=demo; Path=/; Expires=” .. ngx.cookie_time(ngx.time() + expires)

This will set cookie session = demo for 1 day from current time on path /.

You Might Also Like