Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Registration System 6:08
- Securing Passwords 5:38
- Login Systems 4:53
- Building a JWT 4:52
- Authentication Review 5 questions
- Working with Cookies 4:24
- Require Authentication 5:22
- Logging Out 3:13
- Flash Messages 5:29
- Cookies and Flash Messages 3 questions
- User Profile 9:30
- Reset Password 4:42
- Password Hashing 1 objective

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Now that we have the JWT ready, we will use the HTTP Foundations package to set and retrieve cookies.
NOTE: Because we set our extra parameter to accept an array, make sure you pass the cookie as an array.
Tips for Reading and Writing Cookies
To test reading a cookie after login: on index.php
if (request()->cookies->has('access_token')) {
echo "logged in";
} else {
echo "not logged in";
}
If the cookie isn't working properly, one of the most common reasons is that the COOKIE_DOMAIN in the .env file is not set properly.
When using workspaces it should be YOUR workspace url, which would look something like
COOKIE_DOMAIN=port-80-m1m8flu0vu.treehouse-app.com
When working locally, it should be
COOKIE_DOMAIN=localhost
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
PLUS
Aaditya Raj
Courses Plus Student 3,130 Points1 Answer
-
PLUS
Aaditya Raj
Courses Plus Student 3,130 Points1 Answer
-
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points1 Answer
-
Kaleb Mesho Abraha
1,219 Points0 Answers
-
Thandolwenkosi Sibanda
5,588 Points0 Answers
-
Justin Sorensen
14,734 Points3 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
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