Answer the question
In order to leave comments, you need to log in
Session bug?
There was an incomprehensible bug, or something like that.
user id is stored in $_SESSION['id']
.
On some pages the variable is taken
$id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$id
Why is it assigned to a variable instead of $_SESSION['id']
. echo $_SESSION['id'] // выведет правильное id
$id = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
echo $_SESSION['id'] // уже будет другое значение
if(empty($id) || $id < 1) $id = $_SESSION['id'];
Answer the question
In order to leave comments, you need to log in
Try using the intval() function instead of filter_var. It will also help protect against SQL injection, because it returns false if the passed argument could not be converted to an integer
Wang, that this will work fine
echo $_SESSION['id'];
$idGet = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
echo $_SESSION['id'];
Do you happen to have register_globals = on ?
If you are using Apache, try adding the following line to the site's root folder in .htaccess:
If it is on a hosting, consult with those. hosting support. Perhaps they have somewhere in the settings you can turn it off.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question