RE: [PHP] Explanation of cookie behavior
| From: | Ford, Mike [LSS] | Date: | Thu, 15 Apr 2004 15:36:00 +0000 |
| Subject: | RE: [PHP] Explanation of cookie behavior | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-183476@lists.php.net to get a copy of this message | ||
On 15 April 2004 15:43, Ryan Schefke wrote:
> I'm running a login script where the user enters
> login/password and if it
> matches what I have in my db and their account is active, I set a
> login cookie (login_ck) and an authentication cookie
> (authenticate_ck). If the
> login and authentication cookies are set when the user goes back to
> the login page I prompt with "welcome back.". Now, I refresh the
> login page a few times, sometimes it gives the welcome back prompt.
> Then after anywhere from 2-5 refreshes, it deletes the login cookie
> but the authenticate cookie persists. Any ideas why this is
> happening?
>
> I'm setting my cookies like this:
>
> setcookie ("authenticate_ck", "$daysRemaining"); //set cookie for
> active account, for 30days
>
> setcookie ("login_ck", "$lo", time()+ "60*60*24*30",
> "", "", "0");
> //set cookie for login, for 30days
You're quoting all sorts of things that shouldn't be. The above should read:
setcookie ("authenticate_ck", $daysRemaining); //set cookie for active account, for
30days
setcookie ("login_ck", $lo, time()+ 60*60*24*30, "", "", 0); //set
cookie for login, for 30days
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211