Jump to content

session_start


Amit20

Recommended Posts

Hi friends, i m in learning stages of php. I m creating a login/logout page.

 

Is it necessary to add session_start() in every page of php???

 

As i created one page  to start a session for user. But when i try to echo $_SESSION variable in another page it gives me a Notice as follows;

 

Notice: Undefined variable: _SESSION in D:\public_hmtl\mysite\php\sms\form.php on line 87.

 

again when i mentioned session_start() at the page where i m redirecting the user it show the value????

Link to comment
https://forums.phpfreaks.com/topic/240926-session_start/
Share on other sites

session_start() needs to be executed for every script PHP runs. The easiest way to do that is to put a call to it in all your files.

 

Meanwhile, the most common method way is to put that in just one file and include() it in all the other files. You can then put other "common" actions in there, like checking if a user is logged in or connecting to a database.

Link to comment
https://forums.phpfreaks.com/topic/240926-session_start/#findComment-1237561
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.