ag3nt42 Posted June 11, 2008 Share Posted June 11, 2008 hello again all, quick question about sessions. I've created a session and I "gather" that in order to use the session across multiple pages, I need to place "session_start()" at the head of every page.. Which I had this working before but now i'm getting this error: Notice: A session had already been started - ignoring session_start() in mypath\admin.php on line 2 Link to comment https://forums.phpfreaks.com/topic/109785-solved-quick-session-question/ Share on other sites More sharing options...
revraz Posted June 11, 2008 Share Posted June 11, 2008 What are the first 3 lines of code on the page? Is this a include or a stand alone page? Link to comment https://forums.phpfreaks.com/topic/109785-solved-quick-session-question/#findComment-563374 Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 this is an include, but I want to restrict access on it incase someone decides to get creative <?php session_start(); Link to comment https://forums.phpfreaks.com/topic/109785-solved-quick-session-question/#findComment-563375 Share on other sites More sharing options...
revraz Posted June 11, 2008 Share Posted June 11, 2008 Remove it from the include and make session_start(); the first line of code after <?php instead. It sounds like Headers are getting set in your main page before the include gets called. Link to comment https://forums.phpfreaks.com/topic/109785-solved-quick-session-question/#findComment-563419 Share on other sites More sharing options...
ag3nt42 Posted June 11, 2008 Author Share Posted June 11, 2008 yea I'm starting the session on the first line of index.php then about 15 lines down from that i'm "requiring" admin.php based on wether or not you've passed some checks for admin permissions. I thought that if I didn't have session_start on the included page it wouldn't carry over the session data but it is .. so i don't need the second sessions start on the include page.. to get around the checks I did a reference back to the permissions variable.. I was scared it would not pass the check and still out put the rest of the html on the page... but it stops the whole page soo.. the permission variable checks seems to be enough. thankx for the help revraz Link to comment https://forums.phpfreaks.com/topic/109785-solved-quick-session-question/#findComment-563434 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.