Add --session flag for persistent cookie storage#373
Merged
ryanfowler merged 1 commit intomainfrom Jan 29, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements persistent cookie storage through named sessions, allowing cookies to be saved and reused across fetch invocations.
Changes:
- Added session management functionality with JSON-based persistence in the user's cache directory
- Integrated session support into the CLI via
--session/-Sflag and configuration system - Implemented comprehensive test coverage for session functionality including cookie persistence, expiration handling, and session isolation
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| main.go | Integrated session configuration into the main request flow |
| internal/session/session.go | Implemented core session management including load/save operations and cookie jar wrapper |
| internal/session/session_test.go | Added unit tests for session validation, persistence, expiration, and corruption handling |
| internal/fetch/fetch.go | Integrated session loading/saving into the request lifecycle with error handling |
| internal/config/config.go | Added session configuration parsing and validation |
| internal/client/client.go | Added SetJar method to enable cookie jar configuration |
| internal/cli/app.go | Added --session/-S CLI flag for specifying session names |
| integration/integration_test.go | Added integration tests for session persistence, expiration, and isolation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Implement named sessions that persist cookies across invocations. Sessions are stored as JSON files in the user's cache directory (~/.cache/fetch/sessions/ on Linux, ~/Library/Caches/fetch/sessions/ on macOS). The session name is configurable via --session/-S flag or per-host in the config file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement named sessions that persist cookies across invocations. Sessions are stored as JSON files in the user's cache directory (
~/.cache/fetch/sessions/on Linux,~/Library/Caches/fetch/sessions/on macOS). The session name is configurable via --session/-S flag or per-host in the config file.