doubledee Posted March 10, 2012 Share Posted March 10, 2012 If one file includes another, do I need to start a session in each, or does the included file "inherit" the session? script_1.php // Initialize Session. session_start(); // Require Function require_once('script_2.php'); script_2.php // Initialize Session. session_start(); DO I NEED THIS HERE????????? if ($_SESSION['loggedIn'] == TRUE){ do something } Debbie Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/ Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 It "inherits". The reality is that PHP keeps executing from where it left off - nothing changes, nothing resets, nothing goes away. It's basically the same as copy/pasting the code from script_2 into script_1. Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325698 Share on other sites More sharing options...
doubledee Posted March 10, 2012 Author Share Posted March 10, 2012 It "inherits". The reality is that PHP keeps executing from where it left off - nothing changes, nothing resets, nothing goes away. It's basically the same as copy/pasting the code from script_2 into script_1. So if I start a session in the "including" script, then the "included" script is just plopped into the "including" script and it is like it is all one large master file playing together nicely, right? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325702 Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 Yep. Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325703 Share on other sites More sharing options...
doubledee Posted March 10, 2012 Author Share Posted March 10, 2012 Yep. Okay, thank you! Debbie Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325704 Share on other sites More sharing options...
AyKay47 Posted March 10, 2012 Share Posted March 10, 2012 couldn't you have tested this yourself? Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325723 Share on other sites More sharing options...
doubledee Posted March 10, 2012 Author Share Posted March 10, 2012 couldn't you have tested this yourself? I was testing it when I posted, but then you wouldn't have had anything to say... Debbie Quote Link to comment https://forums.phpfreaks.com/topic/258618-session-and-includes/#findComment-1325750 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.