Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: working with cookies Date: Mon, 26 Oct 2015 23:14:02 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 36 Message-ID: References: NNTP-Posting-Host: panix3.panix.com X-Trace: reader1.panix.com 1445901242 24691 166.84.1.3 (26 Oct 2015 23:14:02 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Mon, 26 Oct 2015 23:14:02 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:97961 In Jeremy Leonard writes: > To setup the cookie I use this code: > from http import cookies > from datetime import datetime, timedelta > cookie = cookies.SimpleCookie() > cookie["session"] = random.randint(0,100000000000000000) > cookie["session"]["expires"] = expires.strftime("%a, %d %b %Y %H:%M:%S +0000") > print(cookie.output()) > To disable the cookie I've only been able to find code to the effect of: > from http import cookies > import os > cookie = cookies.SimpleCookie(os.environ["HTTP_COOKIE"]) > cookie["session"]["expires"]='Thu, 01 Jan 1970 00:00:00 GMT' > cookie["expires"]='Thu, 01 Jan 1970 00:00:00 GMT' > print(cookie.output()) > I seem to only be able to find variations of this code. When your application responds to a client request, the response headers include the current list of cookies. Cookies are deleted by removing them from this list. Where does your application keep track of the cookies it sends to the client? Are you using a web framework? -- John Gordon A is for Amy, who fell down the stairs gordon@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"