This question already has answers here:
Answer
Solution:
You should put your session_start()
at very beginning of scripts
config.php
<?php
session_start();
// do your other code here
in your subviews like index you should put the config.php in the very beginning of line or make a separate php file like session.php
and include it on very beginning of scripts.
The cause of error is that session is trying to start but the page is already sent to the browser or rendered.
or maybe you have a whitespace in opening tag?
Answer
Solution:
Session start should be placed at the top of the script. And don't repeat. To avoid errors, Just put a '@' before session_start command. Example
@session_start();
Source