I tried to make admin panel and I am using sessions , but have problem, session does not work,
$r=mysql_fetch_array($result);
$login=$r["login"];
session_register('login');
Header("Location: protected.php");
<?php
session_start();
if (!isset($_SESSION['login'])) {
echo "Not work";
}
else{
echo "Work";
}
?>
I do not know what the problem is, because in index.php I register session, but in protected.php this session is not set.
Don't use session_register(). It was removed in PHP 5.4.0.
In index.php, add session_start(); to the top and replace your register call with $_SESSION['login'] = 'val';
session_register() is deprecated, read here for more information:
http://php.net/manual/en/function.session-register.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With