juju / persistent-cookiejar

cookiejar is a fork of net/http/cookiejar that allows serialisation of the stored cookies
BSD 3-Clause "New" or "Revised" License
113 stars 76 forks source link

Add Option parameter to enable persistence of session cookies #32

Open orirawlings opened 5 years ago

orirawlings commented 5 years ago

Fixes #29

This PR adds a new option, PersistSessionCookies to the Option struct. This allows users to persist both cookies with an expiry time, and those without. By default session cookies are not persisted (which matches current behavior), nor will any session cookies that appear in the serialized cookies on disk be loaded into the jar.

This PR is motivated by usage of the library within command line tools. In the motivating cases, the user might execute a series of separate commands in their terminal. Each command runs as a separate OS process, so they do not share memory, but they still span a logical session with a web API. Allowing session cookies to be persisted allows that session to continue over the sequence of commands.

orirawlings commented 5 years ago

Looks like #31 was opened between when I originally developed this and worked through legal department at my employer. I think either solution would address my use case. Hopefully, one of them can be integrated. :)

orirawlings commented 5 years ago

cc @rogpeppe

naiba commented 5 years ago

I need this