|
Author |
Message |
doubtme
Junior WebHelper
Joined: 03 Feb 2002
Posts: 4
|
Posted:
Sun Feb 03, 2002 4:34 am (22 years, 2 months ago) |
|
Hi there,
I was wondering if anyone had a reliable way of setting cookies that *don't* expire at the end of the session with IE5.5 - setcookie and the various header methods explained on php.net (http://www.php.net/manual/en/function.setcookie.php) don't seem to have any effect
For the record, the code I am currently using is the MySetCookie function from the above link (code below), called as follows, where $sess_last_visit holds the value of the cookie from the previous visit, or -1 if there was no previous visit:
Code: |
MySetCookie("lastvisit", $sess_last_visit, (time()+31536000), "/", "", 0);
|
MySetCookie:Code: |
function MySetCookie ($CkyName, $CkyVal, $exp, $pth, $Domain, $Secure) {
static $mycky;
$exp = strftime("%A, %d-%b-%Y %H:%M:%S", $exp);
$cookiestr = sprintf("%s=%s; domain=%s; path=%s; expires=%s", $CkyName, $CkyValue, $Domain, $pth, $exp);
$mycky = ( ($mycky) ? "$mycky\n" : "") . "Set-Cookie: $cookiestr";
header($mycky);
}
|
What makes this even more bizarre is that it *seemed* to work, albeit erratically, but now doesn't seem to work at all - and I haven't changed the code!
Any thoughts, suggestions or links would be much appreciated! |
|
|
|
|
doubtme
Junior WebHelper
Joined: 03 Feb 2002
Posts: 4
|
Posted:
Sun Feb 03, 2002 6:21 am (22 years, 2 months ago) |
|
Yeah, MySetCookie is what I'm currently using. The confusing thing is that it *was* working... and now it's not. I've got cookies set to "prompt" in my browser, and the PHPSESSID cookie is getting set, but not the long term one that gets saved to the users hard drive |
|
|
|
|
doubtme
Junior WebHelper
Joined: 03 Feb 2002
Posts: 4
|
Posted:
Mon Feb 04, 2002 8:34 am (22 years, 2 months ago) |
|
Cool, thanks for the method Andrew I'm gonna go try it now. One thought I had... to reset a cookie, do I have to delete the previous value?
By this I mean, the cookie lastvisit tracks when the user last visited (duh:)), but to store the time of the current visit into lastvisit, do I have to delete the existing lastvisit cookie?
Thanks!
Christo
PS: Will let you know the results of your method ASAP. |
|
|
|
|
doubtme
Junior WebHelper
Joined: 03 Feb 2002
Posts: 4
|
Posted:
Tue Feb 05, 2002 11:19 am (22 years, 2 months ago) |
|
Ah hah!
Problem solved... it was a combination of a rather subtle bug in my logic (in hindsight, not surprising), plus the fact that Internet Explorer, once a cookie has been set, does not prompt you if a site is changing the value of that cookie (I've had cookies set to "Prompt" while trying to debug this thing).
Thus, once lastvisit had been set once, I was never prompted again when the value of it was changed... and I expected I would. Hence I assumed the cookie was not being set at all (because the bug in my logic was simply setting the cookie it to its old value - doh!)
Many thanks to those who have helped me in discovering this painfully obvious fact.
Cheers
Christo |
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.170395 seconds :: 19 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
|