I have to code this scenario:

Some user comes to fill a form and while user is at it, session expires; 
User tries to submit form, as session has expired it will take him to login 
page after which he is rediredted to form page with a prefilled form with 
data he filled previously.

my propsed solution: on form submit, check if user session is expired with 
an ajax call, if yes, drop a cookie with values of filled form, user comes 
back to same form, prefill the form from cookie value.

how far I got: not much; I used ajax call to check session expiry with a 
backend call to this function:

def check_valid_session(request):
    session_expiry_date = request.session.get_expiry_date()
    now = datetime.now()
    seconds_left = (session_expiry_date - now).total_seconds()
    if seconds_left <= 0:
        return JsonResponse({'session_expired': True, 'seconds_left': 
seconds_left })
    else:
        return JsonResponse({'session_expired':False, 'seconds_left': 
seconds_left})

in my settings I have:

SESSION_COOKIE_NAME = "sso-sessionid"
SESSION_COOKIE_HTTPONLY = False
SESSION_COOKIE_AGE = 10 
SESSION_COOKIE_DOMAIN = '.mydomain.com'
SESSION_COOKIE_SECURE = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

but in response, I always get seconds_left as something close to 9.999. and 
session_expiry_date keeps increasing itself by 10 seconds each time i hit 
submit and call the backend code above. How to get correct session expire 
time?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e623b707-2014-4511-91f4-7a00420fe196%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to