0

When i use python SimpleCookie object to pick up cookie from http headers, some exception occurs:

cookiestr = "a_em=[BU]co|12345678-901234567[DG]; Expires=Sat, 31 Dec 2016 17:09:50 GMT; Domain=.somesite.com; Path=/"
C = Cookie.SimpleCookie()
C.load(cookiestr)
print C

the output is:

Set-Cookie: a_em=; Domain=.somesite.com; expires=Sat,; Path=/

the cookie value and the cookie expires time is error!

how should i solve this?

macskuz
  • 173
  • 1
  • 7

1 Answers1

1

RFC format for expires should be:

Expires=Sat, 31-Dec-2016 17:09:50 GMT

The full string should be (note quotes)

cookiestr = 'a_em="[BU]co|12345678-901234567[DG]"; Expires=Sat, 31-Dec-2016 17:09:50 GMT; Domain=.somesite.com; Path=/'
joaquin
  • 82,968
  • 29
  • 138
  • 152