It is funny that I always forget that how “Remember Me” works but I just keep in mind how to implement it in PHP. I think it is very necessary for me to write it down so that I can check it from time to time, in case that I forget it again. In this post, I will explain how session works in the common way and I will show you what is the difference between login with remember me and login without remember me. All example code will write in PHP.
When you visit a website in the browser, the website may assign an unique id for you in order to save all your data with this unique id. Therefore, it can restore your data when you come back next time. The unique id is called session id.
Website uses session id to identify an unique visitor. At the first time you access the website, it will generate a session id and send it back to your browser. Normally, the session id will be stored in browser cookie if your browser cookie is enabled. (Usually, the cookie is enabled in all browsers.) To make it more clear, I write an example. The following code will record your visit times in session. Each time you visit this page, it will show your how many times you have visited.
Read more