WordPress provides a couple cookies that track whether the user is logged in and what their user ID is. These are described on this page in the Codex:
After login, wordpress sets the wordpress_logged_in_[hash] cookie, which indicates when you're logged in, and who you are, for most interface use.
WordPress also sets a few wp-settings-{time}-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
If you absolutely must avoid loading wp-load.php
in your download.php
file, you could check for the existence of these cookies in your file using the $_COOKIE
global and parse the wp-settings-{time}-[UID]
cookie to get the user ID ("UID").
In my honest opinion, I think this is a waste compared to just including the following two lines at the top of your download.php
file:
define( 'WP_USE_THEMES', false );
require( './wp-load.php' );
This won't load any theme files or template functions, but will instantly give you access to the core WordPress functions you are looking for. I would encourage you to try it both ways (if you are so inclined) and see the performance difference... it won't be much, especially on a server running PHP7.