Forum Moderators: coopster

Message Too Old, No Replies

SSI and sessions question

Why does session_start() included via SSI start a new session?

         

rycrostud

4:06 pm on Jul 4, 2003 (gmt 0)

10+ Year Member



In an effort to reduce server load the vast majortiy of the site I am currently developing is static. There is one element of each page that must be created on-the-fly and for this I am including a PHP file using SSI.

The problem is that each time session_start() is called in the include file it creates a new session ID instead of using the same one.

Does anyone know why this happens and if there's a way to force PHP to re-use the same session ID?

Thanks.

DrDoc

6:52 pm on Jul 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



session_start() has to be called before anything else. If you're using SSI to include a page, then the headers are not sent/parsed by the included script.

Instead, you want to make the page parsed by PHP, and use a normal <?php include "filename.php"; ?>

rycrostud

12:01 pm on Jul 6, 2003 (gmt 0)

10+ Year Member



I was afraid that would be the answer. I was hoping to avoid having every page going through the PHP parser since only certain parts of it actually require any pre-processing.

Thanks for the advice DrDoc.