Suppose we do an authorization task on the site. The following files are used:
- index.php - file with login form
- captcha.php - captcha file
- singnin.php - file with the send script.
Experimentally, I found that the call to session_start is required in each file:
If we entered something wrong, then an error message is recorded in the session and displayed on the main page (I had a separate question about this)
if(isset($_SESSION['error'])){echo $_SESSION['error'];}In
captcha.phpyou need to generate numbers, which we again write to the session.- In
signin.phpwe verify the entered data with the captcha, that is, we need data from the session.
Considering that all files are interconnected ( captcha.php is output via img to index.php , and singnin is called from index.php via the action attribute), which explains the need to call session_start in each of them?