Fairly easy, many ways to do it but there are a lot of security implications in any method you take, but for simplicity do this.
Make a users table in MySQL and a session table to store PHPSESSIONID and user ID.
Check the username and password against records in the user table, if they pass, let them log in and add a logged in $_SESSION.
Once logged in, get PHPSESSIONID, write that to a $_COOKIE and set the cookie to expire when you want the user to log out (idle time, remember to update it on page refresh though, or don't add one at all to keep them logged in). Write the session ID to the table along with the user id.
When they visit the site next, if the cookie exists check the session table for their ID and set a $_SESSION for logged in again. Make sure you don't overwrite the PHPSESSIONID because otherwise it will log you out when you refresh.
A very basic system with loads of room for improvement but hopefully you will get what I mean.
Don't store passwords in cookies, and you need to watch out for cookie hijacking that can steal your session ID. You might also want to include IP address and User Agent in the sessions table for additional checks. If a cookie is hijacked, the IP address and user agents might be different, and the user won't log in.
This forces them to log in again, and if they can't, they're probably not the account owner.