Answer the question
In order to leave comments, you need to log in
How to fix URL generation in YII2?
Good afternoon,
I take a token from the database cell for password recovery, attach it to an absolute link and some garbage ...
<?php
//сохраняем в переменную токен
$resetToken = $user->password_reset_token;
//генерируем абсолютную ссылку и подставляем в хвост токен
$resetLink = Yii::$app->urlManager->createAbsoluteUrl(['site/reset-password', 'token' => $resetToken]);
?>
//выдаем пользователю ссылку с токеном
Hello, <?= $user->username ?>
Follow the link below to reset your password:
//Непосредственно ссылка
<?= $resetLink ?><br/>
//тестовая строка проверить взятый токен отдельно
<?= $user->password_reset_token ?>
Answer the question
In order to leave comments, you need to log in
Pay attention to https://www.urldecoder.org
So you have to look where the problem is. It's not in the code you provided. Try to withdrawvar_dump($user->password_reset_token);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question