}// end if isset
}// end of main for
dear friends this my code to create cookie by posted values .problem is that it does not create cookie on page load ,it creates when i refresh the page ..what is problem in this code plz help
thanks in advance
If by "not create cookie" you mean it is not in $_COOKIE, that would be correct. setcookie() only sends a HTTP cookie header to the client, it does not touch the $_COOKIE array. $_COOKIE only gets populated (automatically) when it receives a corresponding HTTP cookie request from the browser when it requests a URI. If you want $_COOKIE to be populated at the same time that you set the cookie header (via setcookie()) in a script, then you'll need to explicitly set it in the $_COOKIE array at that time.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation