Write then read a cookie in Python

Nigel Wright 291 Reputation points
2021-11-06T18:34:31.747+00:00

I need to store a cookie on client side then read it back to update information then send it again.
My code passes syntax ok and runs with no errors but doesnt read/write the cookies

def readcookiestring() :
cname = 'nigel1234567890'
global cookiestring
cookiestring = ""
try:
res=make_response()
cookiestring = request.cookies.get(cname)

except Exception as e:
    messagebox.showinfo("rd ",e)

messagebox.showinfo("rd ",cookiestring)
return

def writecookiestring():
global cookiestring
cookiestring="a string"
cname = 'nigel1234567890'
try:
res = make_response()
res.set_cookie(cname, "cookiestring")
except Exception as e:
messagebox.showinfo("wr ",e)

return
Windows for business Windows Client for IT Pros Devices and deployment Other
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.