11-03-2010, 04:11 PM
|
#2 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
|
Quote:
Originally Posted by gillweb
I have a cookie being set but the page needs to be refreshed for the cookie to be written to the page? I have the set_cookie command in the header of my file (before html tags) but even though I've confirmed with the browser the cookie was set It does not write the cookie to the page. After hitting refresh, it is then written to the screen?
Anyone ever come across this? Is there a fix or some thing i'm doing wrong? I have 3 php files, header. php, results.php and footer.php. The form action is to results.php but that page includes the header.php file so shouldn't the cookie be set during the header.php load and then results.php write the cookie?

|
I'm not quite sure what you are asking. The cookie is set when the page is sent out, no refresh is needed for it to be there. What you may be doing is this:
PHP Code:
//Current cookie data //Data:1001 //Lets change this setcookie('data','2002'); echo $_COOKIE['data']; //Will output 1001
The $_COOKIE variable is set at the beginning of every request with what the cookie data is. Setting a new cookie does not change the $_COOKIE array, although the user's cookie will be changed when the page outputs.
|
|
|
|