4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 IE5.5 and setcookie?
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
doubtme
Junior WebHelper
Junior WebHelper


Joined: 03 Feb 2002
Posts: 4

PostPosted: Sun Feb 03, 2002 4:34 am (15 years, 8 months ago) Reply with QuoteBack to Top

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 Sad

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!
OfflineView User's ProfileFind all posts by doubtmeSend Personal MessageMSN MessengerICQ Number
doubtme
Junior WebHelper
Junior WebHelper


Joined: 03 Feb 2002
Posts: 4

PostPosted: Sun Feb 03, 2002 6:21 am (15 years, 8 months ago) Reply with QuoteBack to Top

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 Sad
OfflineView User's ProfileFind all posts by doubtmeSend Personal MessageMSN MessengerICQ Number
doubtme
Junior WebHelper
Junior WebHelper


Joined: 03 Feb 2002
Posts: 4

PostPosted: Mon Feb 04, 2002 8:34 am (15 years, 8 months ago) Reply with QuoteBack to Top

Cool, thanks for the method Andrew Smile 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.
OfflineView User's ProfileFind all posts by doubtmeSend Personal MessageMSN MessengerICQ Number
doubtme
Junior WebHelper
Junior WebHelper


Joined: 03 Feb 2002
Posts: 4

PostPosted: Tue Feb 05, 2002 11:19 am (15 years, 8 months ago) Reply with QuoteBack to Top

Ah hah! Smile
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
OfflineView User's ProfileFind all posts by doubtmeSend Personal MessageMSN MessengerICQ Number
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




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.054818 seconds :: 18 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme