bungle / lua-resty-session

Session library for OpenResty – flexible and secure
BSD 2-Clause "Simplified" License
320 stars 111 forks source link

Example doesn't work resty.session.serializers.json #76

Closed digitalshamansky closed 4 years ago

digitalshamansky commented 4 years ago

Hello, tried to test session, tried to install with opm and luarocks see same error, manual placing modules is also didn't help. Don't know what to check else.

session.lua and session dir with modules exists.

nginx http contains path

lua_package_path '/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/resty/session/?.lua;/usr/local/openresty/site/lualib/resty/?.lua;;';

server { listen 8090; location / { access_by_lua_block { local session = require "resty.session".open{ cookie = { domain = "127.0.0.1" } } if session.present then ngx.log(ngx.ERR, "Session -- " .. ngx.encode_base64(session.id)) else session:start() ngx.log(ngx.ERR, "Started -- " .. ngx.encode_base64(session.id)) end } content_by_lua_block { ngx.say "Hello" } } }

Any suggestions?

/usr/local/openresty/site/lualib/resty/session.lua:276: in function 'open' access_by_lua(lua.conf:14):2: in function <access_by_lua(lua.conf:14):1>, client: 91.218.15.35, server: , request: "GET / HTTP/1.1", host: "nvr.telecom.net:8090" 2019/11/14 21:07:24 [error] 26516#26516: *141487 lua entry thread aborted: runtime error: /usr/local/openresty/site/lualib/resty/session.lua:37: loop or previous error loading module 'resty.session.serializers.json' stack traceback: coroutine 0: [C]: in function 'require' /usr/local/openresty/site/lualib/resty/session.lua:37: in function 'prequire' /usr/local/openresty/site/lualib/resty/session.lua:223: in function 'new' /usr/local/openresty/site/lualib/resty/session.lua:276: in function 'open' access_by_lua(lua.conf:14):2: in function <access_by_lua(lua.conf:14):1>, client: 91.218.15.35, server: , request: "GET /favicon.ico HTTP/1.1", host: "nvr.telecom.net:8090", referrer: "http://nvr.telecom.net:8090/"

Thanks

digitalshamansky commented 4 years ago

Finally it's working, solution is : luarocks install lua-cjson