macskuz
macskuz

Reputation: 173

python SimpleCookie distinguish error

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?

Upvotes: 0

Views: 263

Answers (1)

joaquin
joaquin

Reputation: 85663

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=/'

Upvotes: 1

Related Questions