sonal Posted June 14, 2012 Share Posted June 14, 2012 I'm trying to build a site with modularization concept described in the book. Like, index file contains header.html and footer.html. The header file starts session and it is included in other modules wherever required. I want to include login.php on the index.php. index.php includes header.html, which starts session. Now login.php also needs to get access to session. If I use a statement like session_start() at the beginning of login.php, then it gives me error "session already started in header.html"... And that is true, as it is included at the beginning of the index.php file. Same error appears if I include header.html in login.php.. What is the way around? Link to comment Share on other sites More sharing options...
Paul Swanson Posted June 14, 2012 Share Posted June 14, 2012 Found this in the user contributed notes on the PHP Manual page for session_start(): <?php if (!isset ($_COOKIE[ini_get('session.name')])) { session_start(); } ?> Link to comment Share on other sites More sharing options...
Antonio Conte Posted June 14, 2012 Share Posted June 14, 2012 Login.php will have sessions because you include header.php. No worries 1 Link to comment Share on other sites More sharing options...
sonal Posted June 14, 2012 Author Share Posted June 14, 2012 Hi Antonio, I got it. Thank you.... I should have though of that .. well.. thanks! @Paul, thanks to you too. That one is also great to know and keep in mind... Link to comment Share on other sites More sharing options...
Recommended Posts