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

10-19-2012, 09:51 AM

NogDog

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.