Currently i check user/pass in line 4 while the previous lines contain include php file for config and connecting to database and also a file that contain useful functions…
I wanna know is this wrong to check for Authority after include those file or it’s better to put it at top ?
- Also i’m new in php
require_once(‘includes/config.php’);
require_once(‘includes/connection.php’);
require_once(‘includes/functions.php’);
checkAuthority();
PS: checkAuthority function has session_start() within it, while it’s not at the top right now but still works.
No, it is not wrong unless you are doing something in your included files that should only be done when a user is logged in. It looks though, that you include scripts that are nescessary to authenticate the user (e.g. a database connection).
Also, no one says,
session_start()must be executed before anything else is. There must not be any other output though before you executesession_start()(e.g. anecho). If you would echo something in config.php for example,session_start()incheckAuthority()would fail.