Skip to content

Instantly share code, notes, and snippets.

@viniciuspereiras
Last active December 9, 2021 22:17
Show Gist options
  • Save viniciuspereiras/147ba20fd7c924d874ef920e1768d857 to your computer and use it in GitHub Desktop.
Save viniciuspereiras/147ba20fd7c924d874ef920e1768d857 to your computer and use it in GitHub Desktop.
<?php
$token = $_COOKIE['token'];
$parts = explode('.', $token);
$signature = base64UrlEncode(
hash_hmac('sha256', $parts[0].'.'.$parts[1], 'segredinho_rs', true)
);
if($signature == $parts[2]){
$payload = json_decode(
base64_decode($parts[1])
);
} else{
header('Location: /login.php');
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment