Access User Data from external script inside a custom module The method mentioned at Php Access User Data from external script works for me but only if the script is at the document root. If I move the file into my custom module the user returned is the anonymous user.

So, is there something else to do in order to keep all my files in my module and avoid starting to add custom scripts in the Drupal root folder?

Thanks!
The code snippet is bootstrapping Drupal by assuming it's in Drupal's root path (i.e. require_once 'autoload.php';) To have it runnable from the module dir, you'll have to alter the relative path to make it work from wherever your script is at (e.g. is your module is in DRUPAL_ROOT . 'modules/custom/my_module/scripts/my_script.php' you would have use the path ../../../../includes/autoload.php to reach it). 

Depending on what you're doing, you might want to consider a custom Drupal Console/Drush command as a part of your module instead of a PHP script that has to assume/find the location for bootstapping Drupal.