Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97960
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-10-26 15:57 -0700 |
| References | <b538e4ae-2f64-46b6-ac21-f0959f7cd4a8@googlegroups.com> <n0m1n4$qu7$1@reader1.panix.com> |
| Message-ID | <f4e741a7-f47d-457a-babb-d98d15c9aba3@googlegroups.com> (permalink) |
| Subject | Re: working with cookies |
| From | Jeremy Leonard <jrmy.lnrd@gmail.com> |
On Monday, October 26, 2015 at 4:17:18 PM UTC-4, John Gordon wrote:
> In <b538e4ae-2f64-46b6-ac21-f0959f7cd4a8@googlegroups.com> Jeremy Leonard <jrmy.lnrd@gmail.com> writes:
>
> > Hello,
>
> > I am currently working on a web based program and I'm trying to figure out =
> > how to use cookies. So far I've been able to set a cookie, by importing 'co=
> > okies' from the http library. I seem to be having a hard time figuring out =
> > how to delete a cookie though. My searches seem to take me to code that I'v=
> > e already tried (which doesn't seem to work). I would appreciate any pointe=
> > rs
>
> 1. What code did you try?
> 2. How do you know it doesn't work?
>
> --
> 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"
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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
working with cookies Jeremy Leonard <jrmy.lnrd@gmail.com> - 2015-10-26 12:26 -0700
Re: working with cookies John Gordon <gordon@panix.com> - 2015-10-26 20:16 +0000
Re: working with cookies Jeremy Leonard <jrmy.lnrd@gmail.com> - 2015-10-26 15:57 -0700
Re: working with cookies John Gordon <gordon@panix.com> - 2015-10-26 23:14 +0000
Re: working with cookies Jeremy Leonard <jrmy.lnrd@gmail.com> - 2015-10-26 17:30 -0700
Re: working with cookies John Gordon <gordon@panix.com> - 2015-10-27 01:41 +0000
Re: working with cookies Jeremy Leonard <jrmy.lnrd@gmail.com> - 2015-10-27 05:11 -0700
Re: working with cookies Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-28 08:25 +0000
Re: working with cookies Jeremy Leonard <jrmy.lnrd@gmail.com> - 2015-10-28 12:31 -0700
Re: working with cookies John Gordon <gordon@panix.com> - 2015-10-28 19:47 +0000
csiph-web