Question: What is the best way to securely authenticate a user ?

So far I was thinking of:

* Generate a random `$SALT` for each successful login and store `$logged = md5($hashed_password.$SALT)` into database; delete on logout.
* Store `$logged` into a cookie (If user checked "remember me"). Set `$_SESSION['user'] = $logged;`
* On a visit: Check if `$_SESSION['user']` is set; if not, check for cookie, if data doesn't match, redirect to `login` page.

What are the risks ?

Answer: 
First No need of doing

```
Store $logged into a cookie (If user checked "remember me")

```

Starting the session should be the first thing you should do place `session_start()` on top of your index.php (file which gets executed) . This way a cookie name "phpsessid" gets created on user browser by default independent of weather user is logged in or not . value of this cookie is unique by which you can identify the user after he logs in. So you dont need to create any other cookie for this purpose.
One problem I can see - your solution sounds annoying for people who load your site in multiple browsers at the same time.