Search the Community
Showing results for tags 'session start and include'.
-
Hello all, On my website I use a "body template" to hold contents of various pages, and the body template files will call for a "header template" to display the header contents of the site, like in the following two template files: Note: the "body.php" file runs first. HEADER TEMPLATE FILE 'HEADER.php': ================================ <?php session_start(); //POSITION "A" if (...) { ... } else { ... } ?> <!doctype html> etc etc </head> <body> <!-- END HEADER TEMPLATE FILE --> BODY TEMPLATE FILE 'body.php': ================================ <?php session_start(); //POSITION "B" if (...) { ... } else { ... } include('HEADER.php'); ?> <!-- BEGIN BODY CONTENTS --> Body contents etc etc <!-- END BODY CONTENTS --> <?php include('FOOTER.php'); ?> <!-- END BODY TEMPLATE FILE --> And as you can see, I also use session on the site as well. I learned that session_start() must be placed in the beginning of a file, so currently I have session_start() in both the body.php and HEADER.php files (see positions "A" and "B" in the templates above). Currently the pages are displaying fine but somehow I think I might have missed something. Could someone please let me know if the above use is correct? Or, should I use only one session_start() in one of the two templates? And, which one should I keep (position "A" or "B")? Thanks in advance! Cofa