otuatail Posted June 9, 2009 Share Posted June 9, 2009 Hi all. I have never used cookis on my website. I am trying to test for a cookie and if one is not there set one. I can see all my IE cookies together with the date. I am deleting the cookie each time and a new one is added with the latest time against it. The problem is the value of the cookie is not changing as it should. Any sugestions on this. <?php if (isset($_COOKIE['History'])) { echo ("Cookie = " . $_COOKIE["History"]); } else { $time = time(); setcookie("History", $time); echo $time; } ?> TIA Desmond Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/ Share on other sites More sharing options...
otuatail Posted June 9, 2009 Author Share Posted June 9, 2009 Sorry forgot to mention that the echo cookie is always 1244541191 Desmond. Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/#findComment-852197 Share on other sites More sharing options...
trq Posted June 9, 2009 Share Posted June 9, 2009 This is because once the cookie has been set once, your setcookie() part will never execute again. Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/#findComment-852202 Share on other sites More sharing options...
otuatail Posted June 9, 2009 Author Share Posted June 9, 2009 I realise that but I do deliberatly delete the cookie on my PC. So it has to put on a new wone with a diffrent time() stamp. The cookie is definatly deleted each time in IE. Desmond. Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/#findComment-852221 Share on other sites More sharing options...
otuatail Posted June 9, 2009 Author Share Posted June 9, 2009 No this is strange. I have commented out the set cookie and deleted it from the cooki list, and it is still giving me the value of the none exsistant cookie 1244541191 Desmond. P.S. this is IE8 Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/#findComment-852238 Share on other sites More sharing options...
otuatail Posted June 9, 2009 Author Share Posted June 9, 2009 works in FF Link to comment https://forums.phpfreaks.com/topic/161489-setting-a-cookie/#findComment-852260 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.