I am designing a login system using core PHP, please refer to the following code -
funciton login($username,$password) {
// mysql query to check the username and password
if($res == 1) {
session_start();
$_SESSION['username'] = $username;
$_SESSION['loggedin'] = 1;
return true;
}
}
As you can see that I have started the session inside the login function, someone please tell me is it correct or do i start the session on every page of the applicaion i.e. in the common header file?