Skip to content

Commit

Permalink
More session extension and more configurable session values
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Mar 2, 2020
1 parent fff91ec commit b04d78e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rest/src/rest/system.py
Expand Up @@ -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 """

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b04d78e

Please sign in to comment.