Possible to configure nginx to ignore cache for logged in users in certain roles only?

Here is what I ended up doing:

// Set disable cache for certain roles
add_action('init', 'add_custom_cookie_admin');
function add_custom_cookie_admin() {
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$thisrole = $current_user->roles[0];
  if($thisrole !== 'subscriber') {
    setcookie("disable_cache", $current_user->user_login, time()+43200, COOKIEPATH, COOKIE_DOMAIN);
  }
  }
}
// and then remove the cookie on logout
function clear_custom_cookie_on_logout() {
    unset($_COOKIE["disable_cache"]);
    setcookie( "disable_cache", '', time() - ( 15 * 60 ) );
}
add_action('wp_logout', 'clear_custom_cookie_on_logout');

And then I added this to my nginx cache:

if ($http_cookie ~* "disable_cache") {
set $skip_cache 1;
}

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