PHP Session : Is Session Set?

Session is very important in PHP development path. Lets start to learn a little about session in PHP.

How do you know whether session is set or not!

PHP has a session_id() function to tell you if session is set or not. If no session has started then session_id() will return empty ("") string. If session has started then you will get default 32 characters length session id.

For session_id() to return non-empty characters, which will mean your session is set or started, you need to use session_start(); function before any output(html, js. space, etc) has started.