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 Using Cookies and JWTs for Secure Authentication!
We're ready to add the additional cookie settings: path, domain, secure, and HttpOnly.
Managing the Cookie
function setAuthCookie($data, $expTime)
{
$cookie = new Symfony\Component\HttpFoundation\Cookie(
'auth',
$data,
$expTime,
'/',
'.treehouse-app.com',
false,
true
);
return $cookie;
}
Note
If the cookie isn't working properly, one of the most common reasons is that the domain is not set properly.
When using workspaces it should be treehouse-app.com
. When using your own development server, the domain may be something like localhost
.
This additional setting may change based on the environment in which the site is running, so this would be a good place to use environment variables. We'll be adding environment variables with our JWT.
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