How to use cookies within WP?

jlknauff

New member
Aug 25, 2008
237
1
0
I'm trying to use data from one page that has a custom field and pass it to any other future pages that visitor goes to. In this case, the client has local branches all over the country, so if a visitor goes to the page for a particular branch, I want that phone number to then replace the number throughout the rest of the site. So, on the subpage, I have:


Code:
<?php $_COOKIE['localphone'] = get_post_meta($post->ID, 'phone', true); ?> <p class="hdr-phone"><?php echo $_COOKIE['localphone']; ?></p>

Which works fine on that page, but when I go to another page, the data that was in $_COOKIE['localphone'] is gone.It has something to do with when/how the cookie is written, but I can't seem to get it to where the data isn't wiped out when I go back up a page. What can I do?