Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed React Authentication!
You have completed React Authentication!
Preview
In this step, we'll preserve the user's state and theme states across page refreshes by implementing a cookie that keeps track of (or "remembers") the authenticated user data while logged in.
Resources
Check Cookies in Firefox:
- Open developer console by right clicking and selecting Inspect Element
- Go to Storage tab
- Expand the Cookies menu and select "http://localhost:3000"
Check Cookies in Safari:
- Open developer console by right clicking and selecting Inspect Element
- Go to Storage tab
- Click on Cookies
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
the authUser state resets to
its default value of null.
0:00
There's no authenticated user in state, so
the app redirects me to the Sign In page.
0:00
To fix this,
0:07
we'll use a cookie to keep track of the
authenticated user data while logged in.
0:08
A cookie is a file managed by
the web browser that can save
0:13
information from a website.
0:18
We'll use JavaScript Cookie,
a simple library for
0:20
handling cookies to create,
retrieve, and remove a cookie.
0:24
To get started,
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up