title: Allow only signed in users to see external html site hosted on the same server and domain (in sub folder)
body: <p>I have a PHP site (<strong>site A</strong>, CakePHP 2.3) with its own login system. Then I have another "site" (it's actually an html generated ebook with its own index.html) in the same server, but on a different folder, let's call it <strong>site B</strong>.</p>
  
  <p>I'm trying to allow <strong>only users that have a valid session on site A</strong> (have logged in with valid credentials) to view that ebook (access that index.html file). The main idea behind this is to prevent users from directly sharing site B's URL.</p>
  
  <p>This would be easy if I could check the user's session on Site A from Site B, I could just check the $_SESSION variable, but that's not possible.</p>
  
  <p>What's the simplest way to accomplish this? While not preferably, it's okay if I have to edit that index.html file from site B to add any code that could help with this.</p>
  
  <p>One way I thought about was to do some <strong>javascript redirect</strong> from site A to site B that includes a <strong>POST variable</strong>, if the variable doesn't exist, then nothing is shown. This would require adding some php on that index.html on site B but I'm not sure it's the best solution, I wonder if there's something better.</p>
  
  <p>Also, I have 100s of these ebooks so if it's something I can apply massively it would be much better.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>For clarification, both sites are in the same server and have same "domain". To open site B I use a symlink from site A. For example:</p>
  
  <ul>
  <li><p>Site A URL: <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a></p></li>
  <li><p>Site B URL: PHP Redirect from site A to '/symlink/to/siteB/location/') which in practicality takes user to <a href="http://example.com/symlink/to/siteB/location/" rel="nofollow noreferrer">http://example.com/symlink/to/siteB/location/</a></p></li>
  </ul>