Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 4
    Any ways to save Session itself between script runs?
    – Gtx
    Commented Dec 10, 2015 at 18:37
  • 17
    Can pickle.dump session cookies to a file like pickle.dump(session.cookies._cookies, file) and pickle.load to session like follows cookies = pickle.load(file) cj = requests.cookies.RequestsCookieJar() cj._cookies = cookies and session.cookies = cj
    – Cyril
    Commented Apr 13, 2016 at 14:42
  • 1
    what if I involve proxy?
    – brainLoop
    Commented Nov 1, 2018 at 11:54
  • 5
    For the requests sent to localhost, there could be troubles with login and other cookies returned by web server, if they contain incorrect domain property value. For localhost, web server should return cookies with domain property set to localhost.local, otherwise the cookie will not be applied to the session. In that case use 127.0.0.1 instead of localhost Commented Apr 30, 2020 at 19:11
  • 3
    @SergeyNudnov Many thanks for your comment I wasted a lot of time trying to figure out why session does not handle cookies correctly. Changing domain from localhost to localhost.local solved the problem. Thanks again.
    – Pulkownik
    Commented Jun 3, 2020 at 19:32