Dave Aaron Smith
Dave Aaron Smith

Reputation: 4567

How do you set cookies with Dryscrape?

I want to set cookies, but they disappear.

import dryscrape
dryscrape.start_xvfb()
session = dryscrape.Session()
session.set_cookie('a=b')
session.cookies() # returns []

It looks like session.set_cookie is calling session.conn.issue_command("SetCookie", cookie) where session.conn is a webkit_server.ServerConnection. I tried all kinds of string formats such as

session.set_cookie('Cookie: a=b')

but I've never gotten a cookie to stick around.

Upvotes: 0

Views: 304

Answers (1)

Dave Aaron Smith
Dave Aaron Smith

Reputation: 4567

I needed to use a complete cookie string, something along the lines of

session.set_cookie(
    u'a=b; expires=Thu, 15-Mar-2018 18:37:51 GMT; '
    'domain=.whatever.com; path=/')

Upvotes: 0

Related Questions