Jump to content

Recommended Posts

Hi all
Was wondering if somone could point me in the correct direction for learning about adding a remember me check box to my login script.

I have had a look though some of the other tutorials and the php manual but to be honest not 100% sure on what i am looking for. Would guess that its done by storing a Cookie on the users system yes?

Any help would be great.

Many thanks
Lister777
Link to comment
https://forums.phpfreaks.com/topic/4348-quick-question/
Share on other sites

Right. The gist of it would be to check to see if the cookie exists. If so, then the necessary info will be in there, like usernames or whatnot. If not, then set it:

[code]
<?php

setcookie('login_info', 'username', time()+60*60*24*30);

?>
[/code]

i.e.

[code]
<?php

if(isset($_COOKIE['login_info'])){
    $_SESSION['username'] = $_COOKIE['login_info'];
}else{
    //show login form or something
}

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/4348-quick-question/#findComment-15127
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.