Reputation: 2498
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?
Upvotes: 3
Views: 1339
Reputation: 21
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.
Upvotes: 0
Reputation: 78971
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
Upvotes: 0
Reputation: 5715
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.
Upvotes: 0
Reputation: 80031
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
Upvotes: 3