so for the moment, in the beginning of index.php, i test to see if cookie data needs set (first page load it sets user to "guest", curr_page to "home" - or if the user is logging in, set the correct data - same with logging out, erase cookie data) and each time the cookie data is set/changed, i do something like this:
setcookie("user", "guest"); setcookie("curr_page", "home"); header("Location: /index.php"); exit;
this works perfectly fine. it sets the cookie data (or deletes it on logout) and then refreshes the index page so that the cookie data is available for conditional statements.
but i think there must be a better way to do this other than manually writing the header location for a redirect. is there any way to read the cookie data on the same page load where it is set? i haven't found a way and i've been searching for hours. the only thing i can see to do is to reload. it isn't that big of a concern since it's such a small amount of bandwidth wasted, but using header() seems kind of like a hack. it seems there should be a better way. and (i hope) the site will have some heavy traffic eventually, so the minimal bandwidth multiplied by the number of page loads may actually make a difference.
thanks in advance.
p.s. - the site i'm working on and referring to in this post is http://www.watchmyspending.com
just in case you were wondering. (right now it's in testing, so you can log in with "firstname.lastname@example.org" password is "password")