Jump to content

Archived

This topic is now archived and is closed to further replies.

Lister777

Quick Question

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.