Dont output anything before using header function. And that means anything: new lines, txt etc. As you can see in the error, the output has started on line 17 in login_engine.php. Put all those which would redirect to some other page at the start of your script(and remember, no output at all before that).
please I want to know what the benefit from this code and how it work?
Simple, you check with isset if variable is set 🙂 And if variable (in this case $_SESSION['username']) is set, execute the code.
BTW, why do you need to initialize the password to session? Usually thats not what you need to do. Even better would be that you only store the user id to session. Thats how its normally done.