I want to insert the following session into my database. After writing all this code the server - flask server will return KeyError: "tempOTP". I have also tried to use sessison.get('tempOTP') from where I stored it on the server. Still is not seeing the sessions. I was expecting this code to insert the information collected by the user form in the register.html page. @app.route('/verifyEmail', methods=['GET','POST']) def verifyEmail(): if request.method == 'POST': theOTP = request.form['eotp'] sesOTP = session['tempOTP'] dbName = session['tempName'] dbEmail = session['tempEmail'] dbPassword = session['tempPassword'] dbUser_type = session['tempUT'] dbImgdata = session['tempImage'] if(theOTP == sesOTP): cur = mysql.connection.cursor() ar = cur.execute('INSERT INTO users(name, email, password, user_type, user_image, user_login) values(%s,%s,%s,%s,%s,%s)', (dbName, dbEmail, dbPassword, dbUser_type, dbImgdata,0)) mysql.connection.commit() if ar > 0: flash("Thanks for registering! You are sucessfully verified!.") return redirect(url_for('login')) else: flash("Error Occurred!") return redirect(url_for('login')) cur.close() session.clear() else: return render_template('register.html',error="OTP is incorrect.") return render_template('verifyEmail.html') Continue reading...