Making a "remember login" function
You are doing good. You are referencing a good example. 
The flow will be as below: 


Once the user logs in and have checked "remember me", set the cookie with a unique token for user.
Next time when the user comes back, check the cookie with the token value in DB.
If it matches, allow the user to login.
If the token is missing redirect to login.


Ref: 
http://jaspan.com/improved_persistent_login_cookie_best_practice