Answer the question
In order to leave comments, you need to log in
Why is the session variable removed?
Controller Admin, action panel:
if(!isset($_SESSION['admin'])) // Тут ее уже не существует. Программа зацикливается.
{
session_start();
header("Location: /admin/authorization/");
exit;
}
if (isset($_POST["exit"]))
{
session_unset();
session_destroy();
header("Location: /admin/authorization/");
exit;
}
public function authorization()
{
if (isset($_POST['login'])) {
if ($this->login == $_POST['login'] && $this->password == md5($_POST['password']))
{
$_SESSION['admin'] = 'some';
header("Location: /admin/panel/");
exit;
}
else {
header("Location: /admin/authorization/");
exit;
}
}
}
Answer the question
In order to leave comments, you need to log in
The read callback will retrieve any existing session data (stored in a special serialized format) and will be unserialized and used to automatically populate the $_SESSION superglobal when the read callback returns the saved session data back to PHP session handling.php.net/manual/en/function.session-start.php
session_start must be called before $_SESSION
session_start();
if(!isset($_SESSION['admin'])) // Тут ее уже не существует. Программа зацикливается.
{
header("Location: /admin/authorization/");
exit;
}
if (isset($_POST["exit"]))
{
session_unset();
session_destroy();
header("Location: /admin/authorization/");
exit;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question