reply urllib urlopen(print(replyb'his name shall be set-cookieuser=brian\nreply urllib urlopen(print(replyb'welcome backbrian\nreply urllib urlopen(print(replyb'welcome backbrian\nthis works because urllib request mimics the cookie behavior of web browser on the client--it stores the cookie when so requested in the headers of script' replyand adds it to headers sent back to the same script on subsequent visits also just as in browserthe cookie is deleted if you exit python and start new session to rerun this code see the library manual for more on this module' interfaces although easy to usecookies have potential downsides for onethey may be subject to size limitations ( kb per cookie totaland per domain are one common limitfor anotherusers can disable cookies in most browsersmaking them less suited to critical data some even see them as intrusivebecause they can be abused to track user behavior (many sites simply require cookies to be turned onfinessing the issue completely finallybecause cookies are transmitted over the network between client and serverthey are still only as secure as the transmission stream itselfthis may be an issue for sensitive data if the page is not using secure http transmissions between client and server we'll explore secure cookies and server concepts in the next for more details on the cookie modules and the cookie protocol in generalsee python' library manualand search the web for resources it' not impossible that future mutations of html may provide similar storage solutions server-side databases for more industrial-strength state retentionpython scripts can employ full-blown database solutions in the server we will study these options in depth in python scripts have access to variety of server-side data storesincluding flat filespersistent object pickles and shelvesobject-oriented databases such as zodband relational sql-based databases such as mysqlpostgresqloracleand sqlite besides data storagesuch systems may provide advanced tools such as transaction commits and rollbacksconcurrent update synchronizationand more full-blown databases are the ultimate storage solution they can be used to represent state both between the pages of single session (by tagging the data with generated per-session keysand across multiple sessions (by storing data under per-user keysgiven user' login namefor examplecgi scripts can fetch all of the context we have gathered in the past about that user from the server-side database server-side databases saving state information in cgi scripts