rdkd1970 Posted June 21, 2011 Author Share Posted June 21, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1232877 Share on other sites More sharing options...
fugix Posted June 21, 2011 Share Posted June 21, 2011 As stated before in this thread. You cannot usecthe header() function after any output has been sent to the browser. Triggers your error Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1232887 Share on other sites More sharing options...
rdkd1970 Posted June 21, 2011 Author Share Posted June 21, 2011 This is my header location how can I put it so it goes to this section to be viewed by anyone. It is showing up because the username is not recognized. ????? header("location: view_thread.php?id=$this_id"); Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1232896 Share on other sites More sharing options...
Pikachu2000 Posted June 21, 2011 Share Posted June 21, 2011 Read the stick topic at the top of this forum titled HEADER ERRORS - READ HERE BEFORE POSTING THEM for information regarding that error. Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1232922 Share on other sites More sharing options...
rdkd1970 Posted June 21, 2011 Author Share Posted June 21, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1232954 Share on other sites More sharing options...
Drummin Posted June 22, 2011 Share Posted June 22, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1233197 Share on other sites More sharing options...
Pikachu2000 Posted June 22, 2011 Share Posted June 22, 2011 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 . . . Quote Link to comment https://forums.phpfreaks.com/topic/239906-using-sessions/page/2/#findComment-1233393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.