Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.