Page 1 of 1

Multiple call to session_start()

Posted: Sat Mar 26, 2011 12:58 am
by rasspass
I have the following PHP codes:
include.php

Code: Select all

<?php
session_start();
?>
and page.php

Code: Select all

<?php
session_start();
include("include.php");
?>
and get the following warning:
Notice: A session had already been started - ignoring session_start() in C:\wamp\www\session\include.php on line 2
Of course my project has several files but have the same issue as above. How would I solve this without turning warning switches off in php.ini file. Your help is appreciated. Thank you in advance.

Re: Multiple call to session_start()

Posted: Sat Mar 26, 2011 11:42 am
by califdon
The simplest way is just don't use session_start() in a file that will always be included, and always use session_start() in any other file that needs it. If the main file always has it at the beginning, you shouldn't repeat it in another file that's simply going to be copied into the main one.