Skip to content

Fix: Specify domain when setting cookies to prevent conflicts#34

Merged
Aran404 merged 1 commit intoAran404:mainfrom
ParkJeongseop:main
Jun 30, 2025
Merged

Fix: Specify domain when setting cookies to prevent conflicts#34
Aran404 merged 1 commit intoAran404:mainfrom
ParkJeongseop:main

Conversation

@ParkJeongseop
Copy link
Copy Markdown
Contributor

Problem

The application was encountering a CookieConflictError when trying to access cookies:

tls_client.cookies.CookieConflictError: There are multiple cookies with name, 'sp_t'

This error occurred because cookies were being set without specifying a domain initially, and later the same cookie name (sp_t) was set with the .spotify.com domain, resulting in duplicate cookies with the same name but different domains.

Solution

Modified the from_cookies method in spotapi/login.py to explicitly specify the domain when setting cookies:

# Before
cfg.client.cookies.set(k, v)

# After  
cfg.client.cookies.set(k, v, domain=".spotify.com", path="/")

Changes

  • Updated line 118 in spotapi/login.py to include explicit domain specification
  • Ensures all cookies are consistently set with the same domain
  • Prevents cookie conflicts when the same cookie name is used

Testing

  • Verified that the CookieConflictError no longer occurs
  • Confirmed that login functionality works as expected
  • Tested cookie restoration from saved sessions

This fix ensures consistent cookie handling and prevents the duplicate cookie name conflicts that were causing authentication failures.

Explicitly set domain=".spotify.com" when restoring cookies to avoid
CookieConflictError caused by duplicate cookie names.
@Aran404 Aran404 merged commit 793920d into Aran404:main Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants