Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Remember Me option

0 views
Skip to first unread message

pek

unread,
Jan 20, 2006, 8:15:48 PM1/20/06
to
Any ideas on how to create a remember me option in a login box..?

Balazs Wellisch

unread,
Jan 20, 2006, 10:04:41 PM1/20/06
to

"pek" <kimw...@gmail.com> wrote in message
news:1137806148....@z14g2000cwz.googlegroups.com...

> Any ideas on how to create a remember me option in a login box..?
>

You need to save an ID, something you can use to identify users by, to a
cookie. Something like...

$setcookie( 'userId', $userID );

Then when they come back check for the value in the cookie structure.

if (isset( $_COOKIE['userId'] ))
{
$userId = $_COOKIE['userId'];
}

But, you have to be careful with the security risk this creates. At least
make sure that $userId is not a sequential number so it can't be faked to
gain unathorized access to someone else's records.

Balazs


R. Rajesh Jeba Anbiah

unread,
Jan 20, 2006, 10:09:19 PM1/20/06
to
pek wrote:
> Any ideas on how to create a remember me option in a login box..?

<news:1110991855.2...@z14g2000cwz.googlegroups.com> (
http://groups.google.com/group/comp.lang.php/msg/310fad0eef59415a )

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

pek

unread,
Jan 20, 2006, 10:10:17 PM1/20/06
to
I user sessions..
Does that have anything to do with this..?
I mean, I can still use sessions and for the "Remember me" option I
will use cookies..Right..?
I also heard I need to make the cookie expire after a long will..
I tried doing it but didn't know how it works.. :S

Balazs Wellisch

unread,
Jan 20, 2006, 10:19:30 PM1/20/06
to

"pek" <kimw...@gmail.com> wrote in message
news:1137813017.5...@g43g2000cwa.googlegroups.com...

You use the session to track a user's actions through your site. By default
a session lasts as long as the browser is open, but this can be changed.

http://us2.php.net/manual/en/ref.session.php

You use the cookie to identify a user. But when they return the next time
they will probably start a new session.

Here's how to set the expiration of your cookie:

http://us2.php.net/manual/en/function.setcookie.php

Balazs

0 new messages