Cookies and Session Recovery

Hey @meredydd -

Non-urgent question for whenever you get back to work this week.

I’m building a game that uses phone numbers as user_id, so I’m working with the Anvil users service but not using the fully built-in login_with_form(), etc.

I have been trying to make Anvil recover from a SessionExpiredError automatically. Here’s the weird thing: it looks like after the 30 minute session expiration and calling reset_session, cookie behavior gets weird.

Specifically:

  • You can’t read original cookie made before the timeout
  • You can write new cookie and read from it
  • After refreshing the browser, a cookie made after calling reset_session() is lost
  • If new cookie was written, the original cookie is also lost

The last one has less data supporting it, but I’m pretty sure that’s what is happening.

This seems to preclude fully recovering from a server timeout. Is this a bug? Am I missing something?

Thanks much,
Sam

https://anvil.works/ide#clone:FTQEZQ4QHGOF67QO=H7K6YKCK4A5X2QZFEG4TQT47

P.S. A few notes I thought of after writing this:

  1. I realize that using ‘remember me’ could probably work here, but it didn’t 100% work out of the box so I went down the manual path. I suspect that when using the more automatic solution, I was having the same issue?
  2. The workaround I got to (in my real app) was using credentials saved as instance variables within forms to log back in after timeout. Which works initially, but then fails on the next refresh.
  3. Irrelevant: Anvil cookies don’t work on iPhone5 + iOS 7.1 + Chrome. They do on same phone in Safari, and in general cookies work fine with other sites on Chrome. But I’m fine with that, probably not a good place to invest your time. The behavior I describe above seems to be pretty consistent on modern equipment.
  4. Loading a custom page asking the user to refresh the browser could be an OK solution (in my case) if this is not a quick fix.

This definitely does sound like a bug. We will investigate and come back with an update!

[Moved to bug reports]

Hi there!

Just a quick note to let you know that this should now be fixed. Please let us know if you still see any issues around cookies and session recovery.