Hi all,
I’m running into an issue that used to be handled with a simple delay, but now seems to require a full page reload.
Previously, after calling authentication.promptLogin(), I could wait a few seconds (typically 3–5 seconds using setTimeout) before invoking a backend function like createOnlineOrder() for example when using Wix pricing plans that require the customer to create an account first.
The timeout gave time for the session cookie to settle, and things generally worked fine.
Now, even with that delay, backend calls fail — it seems the session isn’t fully established yet. The only reliable fix I’ve found is to refresh the page.
It worked fine for 3 years then last month overnight my code dropped working.
Has there been a change in how login sessions are finalized or how quickly they’re available to backend functions?
Is this reload-based pattern now the recommended approach?
Would appreciate any insight into what’s changed or if there’s a cleaner workaround. Thanks!
yes, there was a change in the session management. I dont think it has been fully documented, but I noticed it around the start of May.
The correct way is to do a page reload…not the best for UX but ensures the session is fully active before making backend calls.
import { authentication, currentUser } from 'wix-members';
import wixLocation from 'wix-location';
// Example backend function you want to call after login
import { createOnlineOrder } from 'backend/yourModule';
export async function promptLoginAndRunAction() {
try {
// Prompt the login popup
await authentication.promptLogin();
// Wait for login to reflect
await waitUntilLoggedIn();
// Try the backend call
try {
await createOnlineOrder();
} catch (backendError) {
// Backend call failed, possibly due to session not ready
console.warn("Backend call failed, reloading page to retry...");
wixLocation.reload(); // Retry after reload
}
} catch (err) {
console.error("Login failed or cancelled", err);
}
}
// Helper: Wait until frontend recognizes login
function waitUntilLoggedIn(maxTries = 10, delay = 500) {
return new Promise((resolve, reject) => {
let tries = 0;
const check = () => {
if (currentUser.loggedIn) {
resolve();
} else if (++tries >= maxTries) {
reject("Login did not finalize in time");
} else {
setTimeout(check, delay);
}
};
check();
});
}
@Dan_Suhr Thanks for this. It’s what I assumed but to make such a change without informing users is not great, as it is a code breaking change.
@noahlovell I wonder if you could check with the team and see if this was an intentional change?
Just asked the team 
(Just a heads-up - the team I contacted is off today for a local holiday, so I’ll likely hear back from them tomorrow)