'Set a custom expiration for the session. ``value`` can be an integer,
a Python ``datetime`` or ``timedelta`` object or ``None``.
If ``value`` is an integer, the session will expire after that many
seconds of inactivity. If set to ``0`` then the session will expire on
browser close.
If ``value`` is a ``datetime`` or ``timedelta`` object, the session
will expire at that specific future time.
If ``value`` is ``None``, the session uses the global session expiry
policy.'

def set_expiry(self, value):

    if (value is None):
        with suppress(KeyError):
            del self['_session_expiry']
        return
    if isinstance(value, timedelta):
        value = (timezone.now() + value)
    self['_session_expiry'] = value
