Xtremer360 Posted March 1, 2012 Share Posted March 1, 2012 Time to ask a stupid question. I have a remember me cookie being set for my login page but I'm wondering what I need to do so that the next time the user comes back to the login page it already has the checkbox checked and the username in the username field which is the cookie. Quote Link to comment https://forums.phpfreaks.com/topic/258056-remember-me-cookies/ Share on other sites More sharing options...
PravinS Posted March 2, 2012 Share Posted March 2, 2012 It depends on requirement, if cookie is set then user will be directly logged in without login screen or else you can come to login page and fill the login screen using cookie data, so that user can use same login details or can change it and submit the form. May this will help u Quote Link to comment https://forums.phpfreaks.com/topic/258056-remember-me-cookies/#findComment-1322997 Share on other sites More sharing options...
creata.physics Posted March 2, 2012 Share Posted March 2, 2012 It depends on requirement, if cookie is set then user will be directly logged in without login screen or else you can come to login page and fill the login screen using cookie data, so that user can use same login details or can change it and submit the form. May this will help u Um, if the cookie is set than the cookie is set, that is all. Only if the script is built to log the user in IF a cookie is set, will it log a user in automatically. Time to ask a stupid question. I have a remember me cookie being set for my login page but I'm wondering what I need to do so that the next time the user comes back to the login page it already has the checkbox checked and the username in the username field which is the cookie. You need to make an if statement to produce the appropriate html to render what you need. <?php if ( isset ( $_COOKIE['username'] ) ) { $preparedUsername = ' value=' . $_COOKIE['username'] . ''; $rememberMe = ' checked'; } print '<input type="text" name="username"'.$preparedUsername.'><br />'; print '<input type="checkbox"'.$rememberMe.'>'; I'm assuming if a user does not check remember me than a cookie is not set and sessions are used instead and vice versa. That is why I only checked to make sure that there is a cookie set to know if we should keep the box checked. I personally feel doing it this way is a drag, if you are to check a box that says remember me you would it expect it to automatically log you in on the next visit. I'd only do it your way if this was a bank or other type of business that handles money, credit cards, etc. Quote Link to comment https://forums.phpfreaks.com/topic/258056-remember-me-cookies/#findComment-1323029 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.