How to use cookies within WP?
-
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:
<?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. What can I do?
[ Please do not bump, that’s not permitted here. ]
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘How to use cookies within WP?’ is closed to new replies.