Welcome Guest, Not a member yet? Register   Sign In
how to create a remeber me tickbox on sign in of user

i want to create a remember me when a user sign in on website so next time he visits i can get his login information from his browser and auto fill them.....


1) Add the checkbox to your form.
2) Check to see if the user has checked it.
3) If so generate a random hash code and save it to the users database record.
4) Create and write out a cookie called rememberme with the hash code value.
5) Check to see if they have the cookie when they come back to your web site.
6) Get the cookie.
7) If they do have the cookie use the hash code to find the record in the database.
8) Auto log the user in.

when user make login

i m checking if he has checked remember me checkbox
if he has checked i m generating a hash and setting it in his browser
no when any visit login page i am checking for that cookie if cookie has been set i m geeting that hash code if matched makin that user login

now i want to ask how two users can use remeber me from same browser?

if cookie has been set as he move to that login page he is made logged in....

To stop that from happening store the users ip address in the database record and check it also on login.

This will make sure the the user can only login from one machine.

i dont think that will work you cant get ip adress of system of user if they are accessing through same ip adress like a network or modem they all will have same ip address...

Then add a unique id to the cookie and check that.


lets i added a unique id for that user ,
now how i will get that cookie and check.....

The same way, if you take an associated array and serialize it it will then be a string that you can store in the cookie.
$data = array(
    'id'        => $id,
    'unique_id' => $unique_id

$value = serialize($data);

set_cookie('cookie_name', $value, etc);

$data = unserialize(get_cookie('cookie_name'));

if i will use this so if a user has remembered and i have set cookie
if anyone using same browser to access website he will be automatically logged in by using the previous cookie saved

i thin this will work in the way as is working if a user has remembered on login any one using that browser will be logged in there is no way that it will know that now this is a different user...

Theme © iAndrew 2016 - Forum software by © MyBB