This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We will use the HTTP Foundations package to make it easier to set and retrieve cookies. First, we need to create a cookie with all the detail we wish to set, then we must send that cookie to our browser by passing is through with a response.
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";
}
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
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