I have a PHP page where the first thing I do is set a cookie. To set the data in this cookie I have to do a couple of DB look ups, an XML look up and some math. In the body of the HTML, near the top, I need to display the value of this cookie.
The cookie is setting but on the first load of the page the value is not displaying. If I refresh the page it is set. I can see the cookie is actually setting via Firebug.
It’s almost as if, due to the overhead to get the value for the cookie, the rest of the page is going ahead and loading and is trying to display before the value is in place.
So my question would be, is there a way to “pause” all other processing and output until that cookie is set? I am new to ob_start but I thought wrapping my set cookie function with that would do it, but that didn’t solve it.
Any ideas?
No PHP wont have access to that cookie until the next request.
If the cookie does not exist can you not use the data you are setting in the cookie directly?