feat: Store sessionId info in cookie with localstorage #770
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.
Changes
Related to PostHog/posthog#15026 but with same-root domains
Currently we only store the distinctId in the cookie when using
localStorage+cookie
(the default). This allows us to tie cross-domain sessions together. We don't currently have the$sesid
value stored though, which means Recordings are not linked.This updates the code to allow multiple values to be stored in the cookie, now including the special
$sesid
value.NOTE: One missing thing here is good handling of multiple active domain sessions. For example if I have a session on
posthog.com
and then one onapp.posthog.com
, they will have the samesession_id
. But if the session times out onposthog.com
but not onapp.posthog.com
then there will be two sessions with a race to decide which reset occurs. We could perhaps mitigate this by periodically "refreshing" from the cookie store but this feels overkill for now.Checklist