Cookies are similar to sessions, other than the fact that they are maintained on the client computer in the form of a text file; whereas, sessions are maintained on the server side.
Their main purpose is to keep track of the client's usage and, based on their activity, improve the experience by understanding the cookies.
The cookies attribute is stored in the response object, which is a collection of key-value pairs that have cookies, variables, and their respective values.
We can set the cookies using the set_cookie() function of the response object to store a cookie as follows:
@app.route('/set_cookie') def cookie_insertion(): redirect_to_main = redirect('/') response = current_app.make_response(redirect_to_main ) response.set_cookie('cookie_name',value='values') return response
Similarly...