'Get the number of seconds until the session expires.
Optionally, this function accepts `modification` and `expiry` keyword
arguments specifying the modification and expiry of the session.'

def get_expiry_age(self, **kwargs):

    try:
        modification = kwargs['modification']
    except KeyError:
        modification = timezone.now()
    try:
        expiry = kwargs['expiry']
    except KeyError:
        expiry = self.get('_session_expiry')
    if (not expiry):
        return settings.SESSION_COOKIE_AGE
    if (not isinstance(expiry, datetime)):
        return expiry
    delta = (expiry - modification)
    return ((delta.days * 86400) + delta.seconds)
