Flask Tutorial
About Lesson

In this Flask tutorial we are going to learn How to Work with Cookies in Flask, so cookies are small piece of data stored on the user’s computer by the web browser while browsing a website. Cookies were designed to be a reliable mechanism for websites to remember stateful information or to record the user’s browsing activity, basically in this lesson we want to learn how you can set and get cookies in flask.

 

 

This is our app.py file.

 

 

 

We have created two new routes one for setting the cookie, in this route you can use set_cookie() method from response, you need to give the cookie name and the cookie value.

 

 

The second route is for getting the cookie.

 

 

Now first you need to set the cookie, http://localhost:5000/set

 

 

And after that you can get the cookie, http://localhost:5000/get

How to Work with Cookies in Flask
How to Work with Cookies in Flask