When user logs in with remember me checked, I create a random token using md5 for the cookie.
md5(uniqid(rand(), true));
I append users IP address to their unique user_id and hash that using bcript. (I DO NOT ADD THIS TO THE COOKIE) I store the bcript hash and random token that uses md5 along with their user id into a table. The row will have an auto increment value. The cookie contains the md5 and the auto increment value appended to it.
When the user visits the website, I take the auto increment value of the cookie to look up the md5 hash. If there is a match I hash the users IP address along with the user_id (that was stored in the table) and see if it matches the hash value stored in the same row. If it does they are logged in and I create another md5 hash for their cookie.
I know md5 isn't secure on its own, but I wondered if the extra steps I take with the brcript and IP address makes it safe, or anyone can see some massive security holes in this.
edit: I'll just add that when using Bcript for the ip and user_id, I'm using the php function password_hash that also creates a salt.