0
votes

I have a website where the user can check a checkbox: Remember me. By checking this checkbox it will ensure that the session cookie will have an expire time of 2 weeks. If the same user next day goes to the site he must automatically be logged in. I can do this by putting in the constructor of the main controller an isset(session->userdata['username']), and if its set then that user will be logged in. But my question is, will this be secure? Can't another person just make a custom cookie with a username(which he knows) and it will automatically logs him in? I hope to get some input from you guys:) thank you.

1
Save the cookie value in a table. When user return to the site, check cookie whether that value in the table. If exists log in as the user. - Sreelal P Mohan

1 Answers