Jump to content

Recommended Posts

I added to the top of the page !isset($_SESSION['username']) . This i added to the top of the pages in the forum that need to be part of the session start. so I see it is both pages however the first page is where a user must post their info this page without the var_dump is showing the username where it should but with this new info I put in there it is givng the error message.

 

if (!isset($_SESSION['SESS_ID']) || (trim($_SESSION['SESS_ID']) == '') || !isset($_SESSION['username'])) { 
  header("location: access-denied.php");
	exit();
   }

 

this is the message I got on the new page.

array(3) { ["SESS_ID"]=> string(1) "2" ["SESS_FIRST_NAME"]=> string(7) "Ronette" ["SESS_LAST_NAME"]=> string(6) "Lounds" } 
Warning: Cannot modify header information - headers already sent by

Okay finally I got it I went to the page that you have to submit the form to post to the forum and what was of course missing with the section for username which is why username was not there. It is like the smallest things make it all come together. Thanks everyone for looking out I did learn more things about PHP which is good when you have situations so you can help the next one out.

You mentioned you have session start at the top of each page.  You should only call this one time, probably on the login-form.php page where the user logs in.

 

session_start() needs to be called before any output is sent to the browser in each and every script that will make use of the $_SESSION array.

I totally respect your knowledge Pikachu2000 as you certainly know more than I do.  I however have never used a session start tag except on my login page, and then call upon these session variables in different areas of my site, i.e. $id=session('id'); etc.  Yes this happens before the page is sent to the browser.    I would imagine that if a session variable needed to be changed, I might need to add the session start on the page making this change, though I'm not sure why as session start is already been called when the user logged in.  Anyway, I will keep that in mind should the need arise.

I suppose it's possible that session.auto_start is set to On in your php.ini file. It usually isn't and it's default value is Off, but that may be something to look into. I've never found a need to have it set to On, and can't really think of any real reason to do so . . .

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.