Possum Posted March 16, 2013 Share Posted March 16, 2013 Hi I have no idea what page my user will first arrive on my site so I put session_start(); on every page.. Is that OK.. It seems to work.. Quote Link to comment https://forums.phpfreaks.com/topic/275721-is-having-session_start-on-all-my-pages-ok/ Share on other sites More sharing options...
kicken Posted March 16, 2013 Share Posted March 16, 2013 Sure, it is fine. A lot of apps will route all requests through a single .php file (known as a router) or will have a common .php file that is included at the top of every script. These common php files are where the session_start() (and other initilization type stuff) happens usually so it will happen on every request, regardless of whether the resources being initialized are actually needed for that request or not. Starting a session (or connecting to a DB) is generally needed more often than not in apps that use them so it is convinent to have them initialized in a common location somewhere. The overhead of intializing them is generally small enough that it is not worth worrying about trying to skip them for a few odd pages that may not need them. Quote Link to comment https://forums.phpfreaks.com/topic/275721-is-having-session_start-on-all-my-pages-ok/#findComment-1418968 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.