Closed hcaihao closed 8 years ago
BTW, How to init cookie with some options with start, like:
local session = require "resty.session".start{ secret = "623q4hR325t36VsCD3g567922IC0073T", persistent = true, lifetime = 86400 }
For the second question:
local session = require "resty.session".start{ secret = "623q4hR325t36VsCD3g567922IC0073T", cookie = { persistent = true, lifetime = 86400 } }
I will check that error you are having, it seems to be a bug or something. Btw, I'm also implementing SameSite-cookie flag.
Can you give me a full example where this error occurs. It seems you are also calling save? Is it so that you have never called :open
or :start
?
It goes like this:
-- grap a new session
local session = require "resty.session".new()
-- set parameters:
session.secret = "623q4hR325t36VsCD3g567922IC0073T"
-- start a session
session:start()
-- set some session data:
session.data.x = 1
-- save session:
session:save()
I will change this so that on :save
the session will call :start
if needed implicitly (but I need to think this a bit so that it doesn't cause any problems).
OK, It's my mistake, I forget to call start, the code runs well now! Tks.
I just released a new version 2.4 where this should be fixed (well, I still consider it a bug in a code, but now it at least doesn't crash anymore, if you don't start, but remember that it will overwrite the session if it was started on previous request). So in general, forgetting to call :start
is a bug in client code, I think, but there might be a scenario where it makes a sense.
I think this is fixed now on the latest 2.5. I will close this now. Please reopen if you still feel there is a problem in this. Thanks!
local session = require "resty.session".start{ secret = "623q4hR325t36VsCD3g567922IC0073T" }
I use thie first line to init session is correct, but use the second two lines get an error:
session.lua:86: attempt to concatenate local 'i' (a nil value)
Is this a bug?