August 23, 2010

What happens if I don't call session_start()?

Question by Summer

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?

Answer by WoLpH

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

Answer by Starx

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

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!