'depreciated' does mean that it has become obsolete.
$_SESSION is the current format, in much the same way the $HTTP_POST_VARS has become $_POST.
The Session start command is
PHP Code:
session_start();
and must always (as you say) come at the very start of the page.
Don't worry about starting the session before authentication (I have this system on my site).
All that the session does is store data in server memory and has nothing to do with logins directly - only what you tell it!
For instance, if you start the session and do this...
PHP Code:
$_SESSION['something'] = "boo";
The only thing stored to session memory is "boo".
You will note that in your code, you have an (if) statement, asking the database if there is a row that matches the posted data.
If this is true, then the data is stored to session memory.
The code should read
PHP Code:
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
I must say though that this method is very old and subject to session attacks, using JS URL entries. Passwords should never be stored in memory, especially if they are not encrypted.
Hope this helps a bit