LLeoun Posted March 27, 2009 Share Posted March 27, 2009 Dear phpfreaks, Can anyone please help me to create a program that checks for a cookie's value, let's say every second or two seconds?? Right now I have: $c= $_COOKIE["myidco"]; But it only stores the value that the cookie had when the page was loaded. Thanks a ton in advance! Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/ Share on other sites More sharing options...
Yesideez Posted March 27, 2009 Share Posted March 27, 2009 For something like that on a regular basis you'd need to create what's called a "cron job" http://en.wikipedia.org/wiki/Cron Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795044 Share on other sites More sharing options...
Mark Baker Posted March 27, 2009 Share Posted March 27, 2009 Except surely a cron job is running as CLI, rather than through a browser/web server, so no cookies Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795046 Share on other sites More sharing options...
LLeoun Posted March 27, 2009 Author Share Posted March 27, 2009 what about looping non stop the $c= $_COOKIE["myidco"]; ?? that would do? Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795048 Share on other sites More sharing options...
Mark Baker Posted March 27, 2009 Share Posted March 27, 2009 So please explain why you need to do this !! What changes the cookie? Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795050 Share on other sites More sharing options...
LLeoun Posted March 27, 2009 Author Share Posted March 27, 2009 The php page has an iframe, the page inside the iframe displays videos and changes the cookie's value every time a new video is displayed. I need this value (the displayed video id) in the parent page (the php page) and in a php variable. So far I've done it with javascript but not the part of turning the javascript variable into a php variable, that's what I thought about cookies. Setting the cookie's value depending on the video displayed is done, and working good, but now I need the parent page (the php page that contains the iframe) to get this value, so I have to check for it constantly... Any ideas?? Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795053 Share on other sites More sharing options...
Yesideez Posted March 27, 2009 Share Posted March 27, 2009 If you've got one iframe you can make another and have the HTTP_REFRESH set to 2 seconds. It'll rload the page constantly until you navigate away from the main page constantly checking the cookie. The frame doesn't have to be visible - set it to 0x0 or if that fails, 1x1. Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795058 Share on other sites More sharing options...
LLeoun Posted March 27, 2009 Author Share Posted March 27, 2009 Thanks Yesideez, is a nice trick, very witty but I need the value in the parent page .. imagine I want to change the background of the parent page depending on the cookie's value, how could I do that if the value is inside an iframe. A smaller detail is the annoying loading symbol every 2 seconds at the top of the browser's tab .. Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795070 Share on other sites More sharing options...
Mark Baker Posted March 27, 2009 Share Posted March 27, 2009 Thanks Yesideez, is a nice trick, very witty but I need the value in the parent page .. imagine I want to change the background of the parent page depending on the cookie's value, how could I do that if the value is inside an iframe. A javascript inside the second iframe could write to the parent Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795072 Share on other sites More sharing options...
LLeoun Posted March 27, 2009 Author Share Posted March 27, 2009 I could write a php variable with javascript back to the parent?? please forgive me it's been long in front of the code and now I'm totally dumb Link to comment https://forums.phpfreaks.com/topic/151374-check-for-cookie-value-constantly/#findComment-795088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.