I am trying to print the session id in my flask application using the below code:
@application.route("/")
def login():
sid=session['_id']
print(sid)
return render_template("login.html")
However, I get a KeyError saying that _id is not valid. How can I print the session Id? Note: I have already set the secret key
Edit: My question is different from this question because:
- I am not using flask login
- There are no accepted answers to that question
- The suggested answers don't work for me and I have already mentioned the error I got trying out one of their suggestion
- I don't want to generate a unique session id. Rather I just want to access the session id which is automatically generated for every session.