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!
You have completed Using Cookies and JWTs for Secure Authentication!
Preview
We have an auth cookie being set on login and removed on logout. Now we need to switch our authentication to use this cookie instead of the session.
Decoding the Cookie
function decodeAuthCookie($prop = null)
{
$cookie = json_decode(request()->cookies->get('auth'));
if ($prop === null) {
return $cookie;
}
if (!isset($cookie->$prop)) {
return false;
}
return $cookie->$prop;
}
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
Now we need to switch our authentication
to use this cookie instead of the session.
0:00
Let's create a helper function to make
it easier to read the cookie properties.
0:03
Function DecodeAuthCookie().
0:08
Cookie = json_decode(request()
0:19
cookies->get('auth') and
0:27
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