Strange behaviour of is_user_logged_in() and get_current_user_id()

I’ve run your code and it works fine to me except for the inclusion in file-access.php:

require_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
enable debug to see if there are errors depending on other issues and not regarding these specific code lines.

But.. as per WP documentation: actions reference the earlier action hook where the authentication process is completed and cookies are set is init as suggested in @Mohsin comment so I suggest to use this code in file-access.php

/* you probably don't need a theme */ 
define( 'WP_USE_THEMES', false ); 

/* defining a constant here allows you to exit functions when not needed */
define('FROM_EXTERNAL_FILE',true);

/* unless you've renamed your wp-content folder this path will always point to wp-load.php even in subfolders installations */
require_once(explode("wp-content", __FILE__)[0] . "wp-load.php");

and move the check in your file functions.php which gets loaded with the whole WP environment by wp-load.php

function is_logged_function(){
  if ( !defined ('FROM_EXTERNAL_FILE') )
    return;
  if ( is_user_logged_in()){
    echo "logged";
    echo get_current_user_id();
  }
  else{
    echo "not logged";
  }
}
add_action('init', 'is_logged_function');