Jump to content

Remember me cookies


Xtremer360

Recommended Posts

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.

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.