tags:

views:

73

answers:

4

I'm trying to make many of the pages in my site cache-able as HTML. As a result, I won't be able to call session_start() on those pages. Do sessions work if you don't call them on every single page?

+1  A: 

If you don't call session_start() than you won't have $_SESSION available. But if the page is a static html file anyway than you won't need $_SESSION for that page so you don't have to worry about it.

You only need it on pages where you do something with $_SESSION

WoLpH
A: 

No, they do not work. The session_start() should be placed prior to any other program execution, even before the code that decides if the cached html is going to be presented or normal code execution should occur.

mhitza
A: 

session_starts(), either starts the session, or allows you to use the session variables. If you want to start a session and store values there or you want to use the session values already there then, you must use session_start()

Do sessions work if you don't call them on every single page?

NO

Starx
A: 

Hi,If you want to have most of your pages in html.Then it is better to mod-rewrite those pages from php to html.Then You can use session_start() at any page with html extension on it. check it.