Skip to content

LG-12214: Refresh device cookie on every user event#10606

Merged
aduth merged 4 commits intomainfrom
aduth-lg-12214-permanent-device-cookie
May 13, 2024
Merged

LG-12214: Refresh device cookie on every user event#10606
aduth merged 4 commits intomainfrom
aduth-lg-12214-permanent-device-cookie

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented May 10, 2024

🎫 Ticket

LG-12214

🛠 Summary of changes

Ensures that the "permanent" device cookie is effectively permanent by re-assigning it on each user event.

Additional background from the ticket:

When a user signs in to Login.gov, we set a cookie to uniquely identify that device so that it is remembered for subsequent sign-ins. As seen in the linked code, the cookie is intended to be permanent, which is documented as expiring "in 20 years from now". However, some browsers may impose limits on the duration of cookies. Chrome sets a maximum cookie expiration to 400 days.

Because of this, a user who signs in with the same Chrome device after 400 days will be treated as a new device, thereby triggering new device notifications, and creating a new device entry in the user's account dashboard.

As documented on the same blog post, there are no restrictions which prevent us from refreshing the cookie expiration every time the user signs-in. Currently we do not do this, since we only set the cookie if the cookie isn't already set.

📜 Testing Plan

  1. Go to http://localhost:3000
  2. Sign in
  3. Open "Cookies" tab in browser dev tools to see your cookies
  4. Take note of the expiration of the "device" cookie
  5. Sign out
  6. Repeat Steps 2-4
  7. Observe that the expiration date is extended on your second sign-in

changelog: Bug Fixes, New Device Detection, Extend duration of permanent device cookie on every user event
@aduth aduth marked this pull request as ready for review May 10, 2024 20:31
@aduth aduth changed the title LG-12214: Refresh device cookie on every user action LG-12214: Refresh device cookie on every user event May 10, 2024
@aduth aduth merged commit 441f085 into main May 13, 2024
@aduth aduth deleted the aduth-lg-12214-permanent-device-cookie branch May 13, 2024 12:11
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