The issue you have appears because you set your cookies too late. You have to set it before anything will be rendered. Set your cookies in the your-plugin-file.php
file.
Also you can check if headers were sent or not by calling headers_sent()
function:
add_action( 'init', 'wpse8170_init' );
function wpse8170_init() {
if ( !headers_sent() ) {
setcookie("test_time_".$cookie_id."", $cookies_times, time()+3600);
}
}
Related Posts:
- How to set custom cookies before output
- Insert custom PHP head above in WP pages
- What is PHPSESSID?
- Setting custom cookies in WordPress
- Check if user already visited this post today
- Display message once per session to users with a specific role
- Using Cookie Data For WP_Query Loop
- How to stop loading multiple copies of jquery
- Creating a WordPress form with a PHP script and default header
- Why isn’t my if/elseif/else working correctly here?
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- How to resolve error “Cookies are blocked due to unexpected output.”?
- StudioPress: add meta tag to every page [closed]
- Using a nonce in a Custom Login Form
- Add custom HTML to posts page
- Using PHP to toggle stylesheet and header image, set in cookie
- Mysterious HTTP 404 header in my own scripts
- Change logo based on incoming domain
- How to sanitize my cookie name
- Echo URL of large version of Featured Image
- Setting a cookie upon specific URL visit
- Conditional Header in wordpress
- add_image_size for header_image
- How to Highlight unread WordPress posts?
- Why is my cookie not unsetting upon logout? [closed]
- How to combine wordpress_logged_in cookies in one cookie?
- Responsive Header for Phone
- How to store post ID’s in cookie or session to display the same posts later
- how can i use $_COOKIE[] + PostID to execute the below code?
- iframe does not store session/cookie when refresh parent
- My php header() function is not working [closed]
- “imagejpeg” function is not working in wordpress
- wp-comments-post.php file returns a blank page
- Headers already sent in Pluggable.php / homepage and wp-login error
- Is_front_page inside header.php is always returning true
- Does wordpress templates always in files or in database?
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Moving code from theme header to functions.php
- WordPress wp_redirect error
- Having Issue on Redirecting With Session in WordPress
- linking stylesheets and scripts with functions.php
- My php code is not being executed
- Location of core code for database connection and get_header
- Clickable image link sends people to wrong URL
- unknown issue in ‘header.php’ preventing theme from displaying fully
- How can I use a sliced image As banner? [closed]
- Add meta tags to a custom header
- $_SESSION variable not saving on page refresh or new page
- Is this a correct usage of ob_start() in my WordPress project?
- Change header on pages displaying taxonomy items
- How to set cookies
- Custom CSV exporter – Cannot modify header information – headers
- How to make a cookie be on the whole site instead of being on a specific page/
- How to add Post Tags to a new element in header.php?
- Set cookie for visitor
- Authentication from sub-folder non-wp cookie WordPress
- How to internationalize header image?
- Custom functions for string data calculations
- How do you remove header sitewide from mobile only?
- WP_REST_Response – How to return Gzip answer and add Content-encoding header?
- Triggering a timewall after X days
- Set cookie parameters on wp site – PHP not working?
- How do I use an iFrame for my header in WordPress twenty seventeen?
- WordPress can’t use ZipArchive
- Reliable way to add nonce to HTTP Header in WordPress?
- Fatal error login WordPress [duplicate]
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Display values of current POST request on page
- IF statement not working – Any suggestions?
- Changing ALT-tag for logo in wordpress
- Using Javascript On Page – Header and Footer Now Missing
- Modifying child theme’s header
- Add my footer menu to the header
- Change headers for one custom PHP file
- Premature end of script headers: wp-mail.php?
- setcookie() issues on running with HTTPS on WordPress
- Allow user to choose header style
- Use WP user status (logged_in) to manage access to independent application
- WordPress load javascript file if something… (after the page is loaded)
- Serve cookie free URLs in WordPress without using a CDN
- How to include different html tags in the header for different pages?
- Use header option on wp-login page with a second logo
- Allow user to select location and then set cookie for location in WordPress
- my site show this symbol (::) between site title and tagline
- Use WP_Query Data In Cookie
- Headers Already Sent
- How to set a cookie based on a page Get variable?
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- Changing 2011 theme header image based on user dropdown
- Converting Menu Links to List Elements
- Warning: Cannot modify header information (with a twist)
- Cannot get custom javascript to execute on page
- Cannot modify header information – headers already sent
- Cookie not created in AJAX request
- Why can’t I enter the wordpress admin interface?
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- Keep users logged in Without Remember Me
- Why can’t I enter the wordpress admin interface?
- Dynamic Email Handler with ‘header (“Location: …’
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”