Due to the above error answers, if the session is already running, I just wanted to indicate what you can do:
if (!isset($_SESSION)) { session_start(); }
Then, if $ _SESSION is already running (installed), it will not perform the launch function.
Although there is nothing better than a well-structured layout of the file and folders with a good structure setting. Even if just a simple structure structure that separates business logic from presentation.
Thus, you will have something similar to a configuration folder with initialization scripts, or at least include files in some folder that are included in all pages / scripts.
Then you simply have your session_start() in (depending on your installation) either the very first include file, or in a separate include file, and then include this session file, when necessary, in a specific area of ββthe script.
In any case, you do not need to name it in any other files, as you know that this is simply not required based on your design structure.
If you do not have a file that is always included, at least use the isset() check.
James
source share