Get access to variable from previous pageview, excluding ajax-calls

I found out you could identify ajax requests by the following if-statement

if (defined('DOING_AJAX') && DOING_AJAX) 

So problem solved using

add_action('init', 'set_global_pixelcapival');
function set_global_pixelcapival() {
  if (defined('DOING_AJAX') && DOING_AJAX) { 
    
  } else {
    global $pixelcapival;
    $pixelcapival = pixelcapival();

    global $prev_pixelcapival;
    $prev_pixelcapival="";

    if(isset($_COOKIE['pixelcapival'])) {
        $prev_pixelcapival = $_COOKIE['pixelcapival'];
    }
    setcookie('pixelcapival', $pixelcapival, time() + 1200, "https://wordpress.stackexchange.com/");
  }
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)