Click here to Skip to main content
15,903,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, i'm currently working on a login system in flask, and i want to send session variables to a landing page after the login and then retrieve them there, (NB: I'm not making use of flask-login and i dont want to parse the variables via get method); please, any idea on how to accomplish such?. I'm actually new to flask. Below is the login module.

What I have tried:

Python
@app.route('/login', methods=['GET', 'POST'])
def login():
    login_form = LoginForm()
    if login_form.validate_on_submit():
        email = login_form.email.data
        password = login_form.password.data

        db_email = engine.execute(text("""SELECT * FROM users WHERE email = :email"""), ({ "email": email },)).fetchone()
        db_password = engine.execute(text("""SELECT password FROM users WHERE email = :email"""), ({ "email": email },)).fetchall()
        passw_decrypt = check_password_hash(db_password, password)

        if not db_email or not passw_decrypt:
            flash('Please check your login details and try again.')
            return redirect('/login')
      
        session['loggedin'] = True
        session['EMAIL'] = db_email['email']
        session['ID'] = db_email['id']
        return redirect(url_for('books'))
    return render_template('login.html', form=login_form)
Posted
Updated 25-Apr-20 13:07pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900