Open LeanKhan opened 3 years ago
` if election.password == "" or election.password == None: res = make_response(redirect(url_for('election_vote', link=link))) res.set_cookie('evoting-user-can-vote', str(election.id), expires=int(datetime.timestamp(election.ending_at)))
return res
`
Okay you want to set a cookie if there's no password for this election. A common issue I faced with setting cookies is the Expiring_at time. To delete a cookie from the backend you have to set that cookie's Expiring time to the past or 0. If you try to set a cookie with an expiring_at time in the past, the browser won't save it at all. So check the ending_at if the election and change it to a time in the future and try again.
You can always see the cookie setting in action by looking at the network tab under devtools. After entering the password or navigating to the voting page, check the request for that page in the Nerworks tab. You should see under "Response" a header passed called "set-cookie" this is what tells your browser to create a cookie. Check it out
@LeanKhan I'm not really sure about how to do this. I don't know why this isn't working `if election.password == "" or election.password == None: res = make_response(redirect(url_for('election_vote', link=link))) res.set_cookie('evoting-user-can-vote', str(election.id), expires=int(datetime.timestamp(election.ending_at)))