REMEMBER_COOKIE_DURATION in flask is not working

I am trying to configure my application to expire cookies after some amount of time however they are not working as expected, my cookies don’t get expired at all.

I have the following configuration in my file:

from flask_login import LoginManager
from datetime import timedelta

app.config['REMEMBER_COOKIE_DURATION'] = timedelta(seconds=30)

login = LoginManager(app)
login.login_view = 'login'

The following is my remember_me input:

<input type="checkbox" class="form-check-input" id="remember_me" name="remember_me">
<label class="form-check-label" for="remember_me">Remember me for 1 week</label>

Finally the following is my view function:

@app.route('/login', methods=['GET', 'POST'])
def login():
    if current_user.is_authenticated:
        return flask.redirect(flask.url_for('home'))
    if flask.request.method == 'POST':
        member_username = flask.request.form['member_username']
        member_password = flask.request.form['member_password']
        remember_me = flask.request.form.get('remember_me')

        existing_user = Users.query.filter_by(username=member_username).first()

        if existing_user is None or not existing_user.check_password(member_password):
            flask.flash('Invalid username or password')
            return flask.redirect(flask.url_for('login'))

        if existing_user:
            login_user(existing_user, remember=remember_me)

        next_page = flask.request.args.get('next')
        if not next_page or url_parse(next_page).netloc != '':
            next_page = flask.url_for('home')
        return flask.redirect(next_page)
    return flask.render_template('login.html')

The resources I have already followed:
flask-login: Chrome ignoring cookie expiration?

What am I missing?

Go to Source
Author: sherlock