Skip to content

Commit

Permalink
fix: revert cookie expiration to maintain backward compatibility
Browse files Browse the repository at this point in the history
To ensure backward compatibility, we need to retain the previous cookie expiration time.
This prevents issues when some parts of the application are running an older version of the agent,
allowing for a gradual update to the latest version without breaking functionality.
  • Loading branch information
Joozty committed Feb 26, 2025
1 parent cf5cc88 commit 5535b97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/web/src/session/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export const SESSION_ID_LENGTH = 32
export const SESSION_DURATION_SECONDS = 4 * 60 * 60 // 4 hours
export const SESSION_DURATION_MS = SESSION_DURATION_SECONDS * 1000
export const SESSION_INACTIVITY_TIMEOUT_MS = 15 * 60 * 1000 // 15 minutes
export const SESSION_INACTIVITY_TIMEOUT_SECONDS = SESSION_INACTIVITY_TIMEOUT_MS / 1000
export const SESSION_STORAGE_KEY = '_splunk_rum_sid'
5 changes: 3 additions & 2 deletions packages/web/src/session/cookie-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
import { isIframe } from '../utils'
import { SessionState } from './types'
import { SESSION_DURATION_SECONDS, SESSION_STORAGE_KEY } from './constants'
import { SESSION_INACTIVITY_TIMEOUT_SECONDS, SESSION_STORAGE_KEY } from './constants'
import { isSessionDurationExceeded, isSessionInactivityTimeoutReached, isSessionState } from './utils'
import { throttle } from '../utils/throttle'

Expand Down Expand Up @@ -91,7 +91,8 @@ export function renewCookieTimeout(

const cookieValue = encodeURIComponent(JSON.stringify(sessionState))
const domain = cookieDomain ? `domain=${cookieDomain};` : ''
let cookie = SESSION_STORAGE_KEY + '=' + cookieValue + '; path=/;' + domain + 'max-age=' + SESSION_DURATION_SECONDS
let cookie =
SESSION_STORAGE_KEY + '=' + cookieValue + '; path=/;' + domain + 'max-age=' + SESSION_INACTIVITY_TIMEOUT_SECONDS

if (isIframe()) {
cookie += ';SameSite=None; Secure'
Expand Down

0 comments on commit 5535b97

Please sign in to comment.