setcookies and header send

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);
    }
}