No...
The session_start() function must be the very first thing in your document. Before any HTML tags or other code. Also check if a session is running, if not then start it...
Start a PHP Session[
^]
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
When you are including files you need to check that they exist or your app might crash without the user knowing why your app is not working, error trapping should be in ALL of your code, I am not going to check each of them -
if (file_exists(__DIR__ . '/koneksi.php')) {
require_once __DIR__ . '/koneksi.php';
} else {
echo "We are aware of the page not loading, please retry again in a few whilst you enjoy that much needed coffee. Our support team is hard at work on this!";
}
If Login session is running, all good and well, what IF it is not, you have no alternative but for the page to load nothing -
if(isset($_SESSION['login'])){
return header('location: index.php');
} else {
return header('location: AnotherStupidPage.php');
}
And then we get into the grinding of things... Never Ever but Ever post, link, share, hardcode or time capsule any usernames or passwords, yes EVER. There were already some basic links given above in the comments you can follow on how to do this securely. I would suggest that you read up some more on this (I am busy with an article on how to secure your site "almost" completely, will be posting soon), once you get the hang of security you will be moving up the ranks to a full blown developer, if not you will be seen as a junior wannabe that just started coding. I am sure that is not where you want to be. :)
Work through the PHP tutorial on PDO (PHP Data Objects) where you will use prepared statements -
PHP PDO | Tutorial[
^]
You should also sanitize your data -
Sanitize filters | Tutorial[
^]
The below link is a tutorial on the proper way to create a login/register flow of your app using a class -
PHP PDO Login/Register System[
^]
Also not 100% IF you followed the above links and advice, but 1000% better than waht you have right now!