Python Flask Basics Character Builder Cookies

Why is stuff "obliterated"?

In the video Kenneth says he knows some stuff will be completely obliterated below and then he modifies the save(). I don't understand what and why it will be obliterated. Can someone explain that bit?

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 56,817 Points

The save is sending cookie information back to the browser. The issue is what happens if the cookie being held by the browser already has some data in the json object stored in that cookie? If the response ignores this pre-existing cookie data, it will get overwritten ("obliterated") by the new cookie in the response.

Kenneth's solution is to extract the existing cookie info from the request, update only the parts that have changed via the form, then send the updated cookie info back in the response.

This is a Read-Modify-Write flow that is typically used when updating partial information.

Nice concise answer Chris.

I wish all of that would be in the Video, so far this is the most unclear tutorial on TreeHouse what I have seen. I am like reading topics here on the forum to understand what is going on in Videos.