From b04d78eae3baeb67cbc42e0a4c16c3af668d05d3 Mon Sep 17 00:00:00 2001 From: joamag Date: Mon, 2 Mar 2020 10:16:55 +0000 Subject: [PATCH] More session extension and more configurable session values --- rest/src/rest/system.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rest/src/rest/system.py b/rest/src/rest/system.py index cd4cf63607..3d700deb20 100644 --- a/rest/src/rest/system.py +++ b/rest/src/rest/system.py @@ -92,9 +92,9 @@ is going to be used in the cookie to "notify" the client about the expiration of it """ -DEFAULT_TIMEOUT = 604800 -""" The default timeout (seven days of life) to be used, -note that a "touch" operation on the session will +DEFAULT_TIMEOUT = 2419200 +""" The default timeout (twenty eight days of life) to be +used, note that a "touch" operation on the session will extend the session lifetime and ensure that there's always the same time until expiration """ @@ -1744,7 +1744,14 @@ def set_s(self, name, value): """ session = self.get_session() - if not session: session = self.start_session() + if not session: + timeout = colony.conf("SESSION_TIMEOUT", DEFAULT_TIMEOUT, cast = int) + factor = colony.conf("SESSION_FACTOR", 64, cast = int) + maximum_timeout = timeout * factor + session = self.start_session( + timeout = timeout, + maximum_timeout = maximum_timeout + ) session.set_attribute(name, value) def unset_s(self, name):