mbr / flask-kvsession

A drop-in replacement for Flask's session handling using server-side sessions.
http://pythonhosted.org/Flask-KVSession/
MIT License
168 stars 53 forks source link

session.new not being "fired" #6

Closed andyparsons closed 12 years ago

andyparsons commented 12 years ago

Hi. I have a Flask app that needs to set a custom cookie when new sessions are created, something like this:

@app.after_request
def record_session(response):
    if session.new:
        app.logger.debug('================ NEW SESSION')

This works as expected when using Flask's default cookie storage, but when I switch to flask-kvsession, session.new is always False. Any insights, is this a bug? Thanks!

mbr commented 12 years ago

Hmm,

that is weird, but I can't make an exact deducation from this little information. Can you write a very minimal self-containted sample app to I can try to verify and fix it here?

On Thu, Mar 29, 2012 at 4:22 PM, Andy S. Parsons reply@reply.github.com wrote:

Hi. I have a Flask app that needs to set a custom cookie when new sessions are created, something like this:

   @app.after_request    def record_session(response):        if session.new:            app.logger.debug('================ NEW SESSION')

This works as expected when using Flask's default cookie storage, but when I switch to flask-kvsession, session.new is always False. Any insights, is this a bug? Thanks!


Reply to this email directly or view it on GitHub: https://github.com/mbr/flask-kvsession/issues/6

andyparsons commented 12 years ago

Yes, I'll do that now.

On Mar 29, 2012, at 4:16 PM, Marc Brinkmannreply@reply.github.com wrote:

Hmm,

that is weird, but I can't make an exact deducation from this little information. Can you write a very minimal self-containted sample app to I can try to verify and fix it here?

On Thu, Mar 29, 2012 at 4:22 PM, Andy S. Parsons reply@reply.github.com wrote:

Hi. I have a Flask app that needs to set a custom cookie when new sessions are created, something like this:

@app.after_request def record_session(response): if session.new: app.logger.debug('================ NEW SESSION')

This works as expected when using Flask's default cookie storage, but when I switch to flask-kvsession, session.new is always False. Any insights, is this a bug? Thanks!


Reply to this email directly or view it on GitHub: https://github.com/mbr/flask-kvsession/issues/6


Reply to this email directly or view it on GitHub: https://github.com/mbr/flask-kvsession/issues/6#issuecomment-4830055

andyparsons commented 12 years ago

Although I don't fully understand why, moving the session.new test to an @app.before_request handler works. If I try to detect session.new in an @app.after_request, things work with standard cookie-based sessions, but fail with kvsessions.

At any rate thanks for the quick response and the suggestion to isolate.

Closing this issue.