#32088: Django Database Sessions - Can't Retrieve expire_date from 
request.session
(SessionStore)
-------------------------------------+-------------------------------------
     Reporter:  Nate Pinchot         |                    Owner:  Pallav
                                     |  Parikh
         Type:  New feature          |                   Status:  new
    Component:  contrib.sessions     |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by ahmadkhalili):

 * status:  closed => new
 * resolution:  wontfix =>


Comment:

 Replying to [comment:14 Carlton Gibson]:
 > HI Nate, yes, thanks.
 >
 > In the end I think that's something you should add to a custom backend.
 There's no reason you can't store the value in load, as you suggest, but
 in 15 years it's not been needed and adding complexity to the API here
 isn't something I think we should do for such a niche case.
 >
 I have this problem too, i wanted create new ticket but when i found this
 ticket it's made me happy. suppose we use database backend session, my
 experience to face this problem:

 {{{
 from datetime import datetime
 from django.contrib.sessions.backends.db import SessionStore

 my_session = SessionStore()
 # there is no session key specified, means we want create new db session
 probably
 session.get_expiry_date()
 # get_expiry_date() func tell us new created sessions expiration time(it
 is now in django 4, 14 day), that is logical and expected

 # we have specific session key means we want work on our db session and
 don't want new
 my_session = SessionStore('some_session_key')

 # get_expiry_date() always return new created sessions expiration time (14
 days after .now())
 if my_session.get_expiry_date() < datetime.now():     # so this is fail
     my_session.create()
     ...
 }}}


 Here in this example django force us using
 `my_session._get_session_from_db().expire_date` instead
 `my_session.get_expiry_date()`, but one simple question: why we should do
 additional work when we determined to django 'we have specific db session
 to work on it' ?

 All i want say in one sentence: get_expiry_date() should return expire
 date of current session but when we have not eny session yet(like
 `SessionStore()`) its logical get_expiry_date() returns new created
 sessions expiration time.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32088#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.8938d1988539bbefa75d6a539a3d9983%40djangoproject.com.

Reply via email to