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?
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
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.
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