This line (at least) is being output before the cookie can be set:
echo '<h2>'.$hash.'</h2>';
Sending output to the screen (even empty lines) will prevent cookies being set.
From the PHP docs:
Like other headers, cookies must be sent before any output from your
script (this is a protocol restriction). This requires that you place
calls to this function prior to any output, including<html>
and
<head>
tags as well as any whitespace.
Related Posts:
- What is the criteria for pluggable functions?
- How to overwrite / extent wordpress function is_email
- Why There Is No “get content by ID” Function
- How to override parent functions in child themes?
- Adding a second email address to a completed order in WooCommerce [closed]
- How to override a function when isn’t at functions.php
- How do I use the WP image functions in a page template?
- Removing custom background and header feature in child theme
- syntax for remove_filter in parent theme with class
- Is it possible to override this function/class in a child theme?
- How to prevent deleting of comments when deleting a post
- Convert hyphen to underscore in permalinks
- Conditional tag is_page with a custom post type
- How to override filter in child theme?
- Customized wp_new_user_notification
- change default option in wp_dropdown_categories
- WP_Remote_Get Not working
- Use register_setting() in a loop
- How to edit the Tags within the image file URLs?
- How to target post and pages and not all post types in admin?
- the_posts_pagination() function returns missing page numbering on some blog pages
- Filter an WordPress Function in (general-template.php)
- Auto log in hook is requiring a page refresh
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- overwrite code snippet from parent to child theme
- Where to store credentials used in a function? [duplicate]
- Solution dealing with Child Theme / Parent theme functions
- How to override this theme function in child theme
- WordPress login set cookie that survive browser exit (wp_signon function)
- I have an fatal error on my funcyions.php
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- WordPress reading old version of functions.php, breaks site
- Providing fallback function and allow override by plugin
- Integrate WP Tiles into existing loop (index.php) and theme
- disable WP_error: authentication_failed
- save_post hook – headers already sent?
- Override default password nag in WordPress
- is_preview() always return false
- Customize Notification Email Sent to New User When Manually Created by Site Administrator
- Automatic Logout on from another active session
- How to debug vars inside function at functions.php file?
- Can’t get post ID in functions.php?
- Logout/login redirect CSS issue
- How to style current page number (wp_link_pages)?
- Stripping shortcode from custom excerpt function
- Gallery images titles – get from post
- Display the number of user comments
- Issue adding text after short description on product pages Woocommerce [closed]
- Child theme functions.php not executing
- How to add background image control to page admin controls?
- Retrieve post modified date for specific post by post ID
- add a function to submit options.php
- Is it better to assign functions like get_the_id() to a variable if it’s used multiple times?
- is_user_logged_in not working to redirect only logged out users
- How to select a page within admin?
- wp_is_mobile dequeue not working
- Loading CDN that requires jQuery in WordPress
- Previous_post and Next_post – Custom Post Type
- Only let plugin add actions to wp_head & wp_footer on single posts
- Gravity Forms Button Text
- Function wont fire after custom post type is updated
- Removing custom meta data
- Conditional Gravity Forms filter in WordPress Multisite
- When a user logs in, how can they view the website instead of the admin menu?
- WordPress Page Restrict
- Do we have to use ftp to recover from a bad functions.php edit?
- Need help getting a function to function
- Load Post into DIV with Ajax
- content editor format style tags
- Custom Behavior when Adding New Custom Post Type in Dashboard
- Does size of a theme’s functions.php file matter?
- How to add custom user avatar in wordpress
- custom functions in function file delete automatically daily
- Fill empty custom field with other custom field
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- Editor cannot access Theme Options
- Is this a backup door?
- Include widget file in functions.php of child theme
- Is there a function for setting a password to a post?
- WordPress functions.php conditional include another functions file
- wp enqueue style on about us page
- CF7 select value get to function and reciept value from function
- Remove nofollow from internal comment links via functions.php
- How can I automatically delete comments that contain a URL?
- Run function for specific user only
- Why is the term of my current page not returning a slug?
- Conditionally apply css for a specific template part
- Fatal error: Call to undefined function. Underscore me
- Setting Active Nav item (of Pages) when you are on a Post with Category
- How to disable site title and description when custom header is uploaded on the customizer?
- How to run a function when publish posts? [duplicate]
- What is wrong with functions.php? Fills error log with same error
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- pluggable function in theme, to be overridden by plugin
- Random text changing to weird icons in both admin & front end
- Pass jquery var to a function in functions.php
- Dynamically adding Captions to images
- How about many “require_once” will affect the page load speed? [closed]
- Removing all Category pages with one exception
- HELP: Code To Check Status And Write Debug Entry