# Checking auth0.is.authenticated cookie vs storing session cookies

**URL:** <https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781>\
**Category:** Get Help\
**Tags:** react\
**Created:** [March 20, 2021, 3:06pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781 "2021-03-20T15:06:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmorin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmorin/32/26307_2.png) [@dmorin](https://community.auth0.com/u/dmorin)\
**Post date:** [March 20, 2021, 3:06pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781/1 "2021-03-20T15:06:22Z")

</div>

Hello community!

After authentication, Auth0 stores a cookie called auth0.is.authenticated.

I’d like to check the status of this cookie before invoking a call to authenticate the user again.

Essentially, piggy back Auth0’s cookie as a defacto session cookie.

The pseudo I’m thinking of is something like: -If auth0.is.authenticated → no call to the login sdk

Is this a robust enough solution to what amounts to a transient user session?

Thanks!

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 22, 2021, 6:09pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781/3 "2021-03-22T18:09:14Z")

</div>

Hello @dmorin!

It’d likely be safest to rely on the [Auth0 SDK](https://auth0.com/docs/quickstarts/) you are using to check if a user is authenticated. For example, in the React SDK this would look like:

```auto
import React from "react";
import { useAuth0 } from "@auth0/auth0-react";

const Profile = () => {
  const { user, isAuthenticated, isLoading } = useAuth0();

  if (isLoading) {
    return <div>Loading ...</div>;
  }

  return (
    isAuthenticated && (
      <div>
        <img src={user.picture} alt={user.name} />
        <h2>{user.name}</h2>
        <p>{user.email}</p>
      </div>
    )
  );
};

export default Profile;

```

As discussed in [this Github issue](https://github.com/auth0/auth0-spa-js/issues/95), `auth0.is.authenticated` is used to determine if a request to Auth0 for [silent authentication](https://auth0.com/docs/authorization/configure-silent-authentication) should take place. Depending on timing, in cases where silent authentication would fail (i.e. an expired session), it’s possible that `auth0.is.authenticated` would be `true` when in fact the user should log in. If you were to use an Auth0 SDK instead, then it will handle the authentication check for you.

---

<div class="post-metadata">

**Author:** ![dmorin](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmorin/32/26307_2.png) [@dmorin](https://community.auth0.com/u/dmorin)\
**Post date:** [March 30, 2021, 8:48pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781/4 "2021-03-30T20:48:48Z")

</div>

Hi @stephanie.chamblee ,

I’ve been elbow deep in some other stuff.

Thanks for the refresher. I was able to achieve the result I wanted with your help.

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [March 30, 2021, 10:06pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781/5 "2021-03-30T22:06:32Z")

</div>

Glad you were able to implement a solution!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 14, 2021, 10:06pm UTC](https://community.auth0.com/t/checking-auth0-is-authenticated-cookie-vs-storing-session-cookies/59781/6 "2021-04-14T22:06:47Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
