Auth0 Home Blog Docs

Due to cookies, stats.loginsCount does not reflect expected behavior

I need to show a user a certain page if they have just created an account & been logged in for the first time. When I brought this up previously, I was given this solution.

However, the way it works does not reflect expected behavior.

For instance, if I click “Sign out” on my site (which runs auth.logout), the login component does indeed toggle to its logged-out state (i.e. it says “Sign in”). However, if I then click “Sign in” again and review both the browser cookie and the login stats in Auth0, stats.loginsCount remains at 1.

I even created a custom rule to try and iterate this number myself:

function (user, context, callback) {
  const namespace = 'https://another.site.com/';
  const count = context.idToken[namespace + 'processed_logins'] || 0;
  context.idToken[namespace + 'processed_logins'] = count + 1;
  console.log("iterating login count", context);
  callback(null, user, context);
}

Unfortunately, the processed_logins value remains at 1 as well.

Can you help me understand why this is the case, and what I can do to actually iterate this value?

The page I want to show the user on first login is essentially a “now confirm your email” page, and seeing that page over and over again would of course be annoying.

Thanks!

1 Like

Any thoughts here? This is a pretty big issue for us.