title: How to block access to directory if user is not logged in
body: <p>I was wondering if someone could help me on how to approach this problem.
  For example lets say I have a index.php page where in which a user must login to gain access to home.php where in which they can click a link to a pdf document which opens up in their browser.</p>
  
  <p>HTML link </p>
  
  <pre><code>&lt;a href="example.pdf"&gt;example&lt;/a&gt;
  </code></pre>
  
  <p>How can I stop a user who isn't logged in from searching for the pdf document and opening it without logging in. i.e <code>www.exampledomain.com/example.pdf</code></p>
  
  <p>I would like to know how to block access to the directory, I am not sure if i need to change the way in which I link the pdf to the page or if need to change or add something else.</p>