Any ideas on how to create a remember me option in a login box..?
Remember Me option
Collapse
This topic is closed.
X
X
-
pekTags: None -
Balazs Wellisch
Re: Remember Me option
"pek" <kimwlias@gmail .com> wrote in message
news:1137806148 .178510.59470@z 14g2000cwz.goog legroups.com...[color=blue]
> Any ideas on how to create a remember me option in a login box..?
>[/color]
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
Re: Remember Me option
pek wrote:[color=blue]
> Any ideas on how to create a remember me option in a login box..?[/color]
<news:111099185 5.257652.244240 @z14g2000cwz.go oglegroups.com> (
http://groups.google.com/group/comp....0fad0eef59415a )
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Comment
-
pek
Re: Remember Me option
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
Comment
-
Balazs Wellisch
Re: Remember Me option
"pek" <kimwlias@gmail .com> wrote in message
news:1137813017 .516906.245940@ g43g2000cwa.goo glegroups.com.. .[color=blue]
>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
>[/color]
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.
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:
Balazs
Comment
Comment