How the Session works in browsers
I have this Django code which get the "msg" from the session and save it to a variable msg then check if the msg is true if true it will delete it from the session but still the msg variable contains the old value. I know i can set the msg to False in the if block but is there another way of doing this
def get(self, request):
msg = request.session.get("msg", False)
if msg:
del request.session["msg"]
context = {"message": msg}
return render(request, "guess_form.html", context)
def post(self, request):
guess = request.POST.get("guess")
msg = checkGuess(guess)
request.session["msg"] = msg
return redirect(request.path)
I Want to make the msg to be empty when the app runs for the first time the msg meaning the variable