Help to clarify a simple question, I study php, I can not understand one simple thing with going to the address in the action tag.
I do this, in the auth.php file auth.php check empty input or not, if there is no old session and add auth = true to the main array
//auth.php if (!empty($_REQUEST['test'])) { session_start(); $_SESSION['auth'] = true; } else { echo 'Пустой инпут'; ?> <form action="" method="get"> <input name="test"> <input type="submit" value="SEND"> </form> <?php } I go to the second index.php file and check that true is displayed, the session is working at this stage, everything is clear.
//index.php session_start(); //стартуем сессию if (!empty($_SESSION['auth'])) { echo 'true'} else { echo 'false'; } But if I prescribe action="index.php" in the action tag in the auth.php file, then when I redirect to index.php, I get false.
As I understand it, this is due to the fact that in the first case the auth.php file auth.php read two times and as a result the session starts and in $_SESSION['auth'] writes true , and in the second case the second reading does not occur and the redirection goes right to index.php , where essentially $_SESSION['auth'] is not at all.
How to be in such a situation I can not understand