Hello I have a question that is driving me crazy. I am trying to set a cookie after the page has loaded for 1 minute. Currently in my script I set it to activate the cookie after 12 seconds. but it doesn't seem to work. Please help me.. Thanks

<script type="text/javascript"> 
jQuery(document).ready(function($) {
   var hour = 0;
   var minutes = 0;
   var secs = 12;
   var thisdelay = (hour*60*60*1000) + (minutes * 60 * 1000) + (secs * 1000);
   
     $.cookie("myppix", "<?php echo "$mypp"; ?>").delay(thisdelay);
   };         

//prevents jQuery 1.5.1 and 1.3.2 from conflicting
jQuery.noConflict();        
</script>

Method-chained jQuery executes left to right. There's no point setting a delay with nothing to its right; it won't affect anything to its left.

You can try the following but it doubt it will work because .cookie() isn't in the effects queue or a custom queue.

$.delay(thisdelay).cookie("myppix", "<?php echo "$mypp"; ?>");

jQuery is not right for this type of delay. Standard javascript will do it reliably (whilst still using jQuery for the cookie):

setTimeout(function(){
    $.cookie("myppix", "<?php echo "$mypp"; ?>");
}, thisdelay);

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.