Get cookie when logged out
-
Hi,
I’m setting cookies with JavaScript (due to caching problems) and retrieving them with php in my functions.php.
Setting the cookie is fine. Retrieving works but only when logged into WordPress using the following. However I need logged out site visitors to get the cookies. Any help would be appreciated. (Please no “echo” examples unless echoing into the value needed for $supercookie below). Thanks.
add_action( 'init', 'accounturl_shortcode' ); // does this do anything? add_shortcode('accounturl', 'accounturl_shortcode'); function accounturl_shortcode( $atts ){ $output = ''; $supercookie = ''; $supercookie = $_COOKIE['cookiename']; //have tried this here but doesn't work: if (isset($_COOKIE['cookiename'])){ $output = 'https://domain.com/index.php?'.$supercookie.''; return $output; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Get cookie when logged out’ is closed to new replies.