mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #5865] feat(cookies): Auto-extract and persist cookies from API responses #5382
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#5382
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/5865
Author: @yoga-ford
Created: 2/11/2026
Status: 🔄 Open
Base:
main← Head:FOSS-auto-cookie-management📝 Commits (4)
fbc8800updated automatic cookie management logic to align with the recent branch newchanges3ae5abefeat: add cookie persistence to cookie jar servicedd899c8fix(common): cookie deletion not working for GET requests96e2164Issue #5864 - PR-5865, Fixed security vulnerability reported by cubic as PR review📊 Changes
7 files changed (+540 additions, -14 deletions)
View changed files
📝
packages/hoppscotch-common/locales/en.json(+1 -0)📝
packages/hoppscotch-common/src/components.d.ts(+3 -0)➕
packages/hoppscotch-common/src/components/http/Cookies.vue(+185 -0)📝
packages/hoppscotch-common/src/components/http/RequestOptions.vue(+23 -0)📝
packages/hoppscotch-common/src/helpers/RequestRunner.ts(+15 -2)📝
packages/hoppscotch-common/src/helpers/kernel/rest/response.ts(+33 -1)📝
packages/hoppscotch-common/src/services/cookie-jar.service.ts(+280 -11)📄 Description
Automatic Cookie Management with Local Storage Persistence
Closes #5864
Summary
This PR implements automatic cookie management for Hoppscotch Desktop, enabling seamless handling of HTTP cookies across requests with persistent local storage. Cookies received from API responses are automatically captured, stored, and reused in subsequent requests to matching domains, eliminating the need for manual cookie management.
Problem Statement
Currently, users must manually copy cookies from response headers and add them to subsequent requests when testing APIs that require session management. This creates significant friction when:
Multiple users have reported this issue in #1383 (comments from @LMCom, @rishabmahesh) and #5063, indicating this is a real pain point.
What's Changed
Set-Cookieheaders from API responses automaticallyset-cookie-parser-eslibrary following HTTP cookie standardslocalStoragewith Vue reactivity watchersFiles Modified
Core Implementation
packages/hoppscotch-common/src/services/cookie-jar.service.ts(Modified)parseSetCookieString(),bulkApplyCookiesToDomain(),getCookiesForURL(),removeCookie()watch()withdeep: truepackages/hoppscotch-common/src/helpers/kernel/rest/response.ts(Modified)Set-Cookieheaders usingset-cookie-parser-espackages/hoppscotch-common/src/helpers/RequestRunner.ts(Modified)Cookieheader for HTTP requestsUI Components
packages/hoppscotch-common/src/components/http/Cookies.vue(Added - NEW)clearAllCookies()with proper domain matching logicpackages/hoppscotch-common/src/components/http/RequestOptions.vue(Modified)Configuration
packages/hoppscotch-common/locales/en.json(Modified)packages/hoppscotch-common/src/components.d.ts(Modified)Testing Scenarios
✅ Login Flow Testing: Session cookies from login responses automatically available for subsequent requests
✅ Multi-Domain Testing: Cookies properly isolated by domain
✅ Persistence Across Sessions: Cookie jar restored on application restart
✅ Cookie Deletion: Both individual cookie deletion and domain-level clearing work correctly
✅ Domain Matching: Handles
.example.comandwww.example.comvariations properlyNotes to Reviewers
Why This Isn't a Duplicate of #1383: Issue #1383 addressed basic cookie manager UI (manual management). This PR implements automatic extraction and persistence - a new capability that addresses user requests in #1383 comments and #5063.
Backwards Compatibility: This feature is additive and doesn't break existing manual cookie management workflows.
Privacy Consideration: Cookies are stored in local storage, not synced to any backend. This aligns with desktop app privacy expectations.
Vue Reactivity Pattern: The cookie deletion fix creates entirely new Map/Array instances to ensure Vue's reactivity system detects changes. This follows Vue 3 best practices for reactive collections.
Browser vs Desktop: This implementation is specifically for Hoppscotch Desktop where we have full cookie control. The web version has browser security limitations that prevent similar functionality.
Related Issues
Ready for Review ✨
Summary by cubic
Automatically capture cookies from API responses, persist them locally, and reuse them in future requests in Hoppscotch Desktop. Adds a simple cookies tab to view and manage domain cookies, improving multi-step and session-based API testing.
New Features
Bug Fixes
Written for commit
96e2164dfa. Summary will update on new commits.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.