Prevent direct access to uploads folder for non-loggedin user (WordPress)

Solution:

I have fixed it, So basically I need to prevent the direct access to a folder which is inside the wp-content/uploads folder. So I just created .htaccess files inside that folder and put following rules and it’s working fine now. Thanks all

    RewriteEngine On
    RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC]
    RewriteRule ^(.*)$ - [R=403,L]