pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
507 stars 238 forks source link

should_set_cookie 这里段为何被注释掉了? #8

Closed humiaozuzu closed 9 years ago

humiaozuzu commented 9 years ago

因为自己并不需要每一次请求的时候都更新 session 的有效期

        #if not self.should_set_cookie(app, session):
        #    return
fengsp commented 9 years ago

This feature is added in Flask version 1.0 which is not released yet.

fengsp commented 9 years ago

It seems we need to add it to our extension, :)

humiaozuzu commented 9 years ago

我自己稍微修改了下这个功能,用了 SESSION_REFRESH_INTERVAL 参数控制多少次请求后才会刷新一下 session,用的 random 函数。因为完全不刷新和每次都不刷新都不太好。

fengsp commented 9 years ago

@humiaozuzu I would consider adding our own should_set_cookie feature.

CyL0NG commented 7 years ago

in the newest version of flask, flask use a config param called SESSION_REFRESH_EACH_REQUEST, which default value is True, it is used to control "should_set_cookie". When it is False, flask won't set cookie in every response. In flask_session, this code is commented, so the SESSION_REFRESH_EACH_REQUEST won't work, can you support this config param?