[GH-ISSUE #197] Multiple instances / sessions #135

Closed
opened 2026-02-27 19:26:14 +03:00 by kerem · 2 comments
Owner

Originally created by @brandonmcconnell on GitHub (Jul 12, 2020).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/197

What is the best practice for having multiple simultaneous Spotify API sessions? I'd like to allow multiple users from around the web to all show what they're listening to simultaneously, which will all display simultaneously from the same dashboard.

Do I just need to start a new SpotifyWebAPI\Session per user? Will that allow the app to continuously read data from their account and refresh tokens without repeated authentication so their status is publicly available? Ideally, one person should be able to see what anyone else on the platform is listening to and be able to also tune into what someone else is listening to, so there will also be two levels of sessions: (1) external sessions of all other users on the platform, and (2) the current user's internal session.

Sorry if this isn't the correct medium for a question like this. Wasn't sure where else to go.

Originally created by @brandonmcconnell on GitHub (Jul 12, 2020). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/197 What is the best practice for having multiple simultaneous Spotify API sessions? I'd like to allow multiple users from around the web to all show what they're listening to simultaneously, which will all display simultaneously from the same dashboard. Do I just need to start a `new SpotifyWebAPI\Session` per user? Will that allow the app to continuously read data from their account and refresh tokens without repeated authentication so their status is publicly available? Ideally, one person should be able to see what anyone else on the platform is listening to and be able to also tune into what someone else is listening to, so there will also be two levels of sessions: (1) external sessions of all other users on the platform, and (2) the current user's internal session. Sorry if this isn't the correct medium for a question like this. Wasn't sure where else to go.
kerem 2026-02-27 19:26:14 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Jul 12, 2020):

Hey!
Yeah, one Session instance per user should do the trick. Reusing the same Session instance could work but it would be more work updating it with the correct tokens. One per user should be easier to work with.

<!-- gh-comment-id:657249650 --> @jwilsson commented on GitHub (Jul 12, 2020): Hey! Yeah, one `Session` instance per user should do the trick. Reusing the same `Session` instance could work but it would be more work updating it with the correct tokens. One per user should be easier to work with.
Author
Owner

@brandonmcconnell commented on GitHub (Jul 12, 2020):

Perfect, thanks!

<!-- gh-comment-id:657253567 --> @brandonmcconnell commented on GitHub (Jul 12, 2020): Perfect, thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#135
No description provided.