Closed dimitrovs closed 7 years ago
@dimitrovs,
Lets keep things separated for a moment, and start with session config. One thing we don't support is human readable shortcuts like 12h (pull requests are welcomed), you should always set settings as seconds. 12h = 43200.
To have sessions expire (when no activity) in 12 hours:
set $session_cookie_lifetime 43200;
The renew setting is basically an optimization that prevents sending a new cookie if the cookie is not going to expire soon. By default we renew cookies that are expiring in 10 minutes (600). Think about it like this:
So, the $session_cookie_lifetime
is the setting you should configure. You can set $session_cookie_renew
to the same 43200 (or larger) for session to be renewed whenever user accesses a resource on server that starts (reconnects) session.
To use shared dictionary for session storage, you need to configure the storage as well:
set $session_storage shm;
set $session_shm_store sessions;
Closing a tab and expiring a session is usually not possible, because browsers tend to have non-persistent sessions available until the browser process is closed, and usually closing a tab is not enough and you have to use ALT-F4 or CMD-Q). But the sessions will of course expire when session cookie lifetime is over.
Another thing, the SSL configuration only affects if you have Session Tickets disabled, and have configured (enabled) this: https://github.com/bungle/lua-resty-session#boolean-sessioncheckssi
Read more from here: https://github.com/bungle/lua-resty-session#nginx-configuration-variables
In general, I don't think this is much used anymore, as most of the users use session tickets.
Thank you!
Here are the settings I have:
lua_shared_dict sessions 10m; ssl_session_timeout 24h; ssl_session_cache shared:SSL:20m; set $session_cookie_renew 12h; set $session_cookie_lifetime 24h;
I want the session to expire ONLY in one of the following cases: 1) User leaves browser tab open for > 12h with no activity 2) User closes browser tab (so not persistent)
Are my settings correct/optimal for this use case? Thanks.