Answer the question
In order to leave comments, you need to log in
How to make a 403 error?
Hello fellow programmers!
Could you help me) The idea is this:
I have registration, authorization on the site. Accordingly, there is also a user's personal account. How to do the following: So that if the user is not logged in or not registered, he could not go to his personal account ("ishop.loc/cabinet.html"), so that an error 403 comes out LIKE THIS
:
Answer the question
In order to leave comments, you need to log in
for yii-2.
just for yii - I don't know. I will find something - I will add the answer.
use yii\web\HttpException;
//some code...
throw new HttpException(403/*or any code*/, 'Forbidden'/*or any message*/);
try {
//any code
} catch (Exception $e) {
echo 'Выброшено исключение: ', $e->getMessage(), "\n"; // any action/message
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question