Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies storing the session id are always treated like session cookies, ignoring the timeout config parameter #746

Open
gentakojima opened this issue Oct 17, 2022 · 0 comments

Comments

@gentakojima
Copy link

The cookie for storing the session id in the web browser is set using self._setcookie in line 155 of sessions.py.

The same method is also called to delete the cookie, so it has a parameter called expires which defaults to an empty string. All the other options are taken from self._config instead inside the method, but not this one.

This means the timeout parameter is ignored, since setting web.config.session_parameters['timeout'] to any value does virtually nothing. If the user closes the web browser, then open it again, the cookie with the session id won't be there anymore so the session can't be recovered.

Changing the line 155 fixes the issue for me and sessions are preserved even if I close and reopen the browser, which I think should be the intended behaviour.

From this:

self._setcookie(self.session_id)

To this:

self._setcookie(self.session_id, expires=self._config.timeout)

Changing the self._setcookie definition just below should cause the same effect, since this method is only called twice, but I didn't test it.

From this:

def _setcookie(self, session_id, expires="", **kw):

To this:

def _setcookie(self, session_id, expires=self._config.timeout, **kw):
@gentakojima gentakojima changed the title Cookies storing the session id are always trated like session cookies, ignoring the timeout config parameter Cookies storing the session id are always treated like session cookies, ignoring the timeout config parameter Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant