Everything goes well, BUT because it creates the hash based on a random string, it could return a hash like this : MI/GUHI39ne+LdjE3gHFaq7kqTw3K6OaQ7thdJAdaWQ=15 (please observe he / character)
so, when we will try like in the example to extract the hash by doing $user = substr($hash, 44), will never reach the user, because the actual $hash is : MI (before /).
Do I miss something or is like that and we have to create another kind of hash ?
I've found this solution on php.net - User contributed note, which seems to do the job. Contributor : gutzmer at usa dot net (link) <font size="3"><font face="Times New Roman, serif"></font></font>
I know this is an old expired thread, but wanted to pop in with my $0.2.
There is an issue with the encrypting. it does send out hashes with / chars. I was scratching my head till I found this thread. A good solution, as found by @mgabrielro is to base64_encode *_decode.
I use this to reset passwords, and loosely followed the example provided. I use the $hash example:
// Check hash isn't null, if it is someone needs redirected //
is_null($hash) and Response::redirect('/');
// Unhash the email hash | Now I have something to work with //
$unhash = base64_decode($hash);
// Get my user //
$user = substr($unhash, 44)
..... // Continue on with code //
}
The extra encoding really isn't a bad idea either, so it's not that much of a hassle, and I personally wouldn't change it. Maybe reflect this in the documentation.