Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Is the content WITHIN the actual page dynamic? What I mean is, do I need to authenticate just to see anything other than the login page, or do I see some things when I'm logged in and other things when I'm not, etc? Because if the entire directory/section of the server is behind a log-in screen you could just add something to the .htaccess file of the directory that redirects anyone not logged in, etc.</p> <p>On the other hand, you could have that file holding the login status included into whatever page/script that the user is viewing, with the included file returning just the login status instead of its entire contents. This is covered under <a href="http://us2.php.net/include/" rel="nofollow noreferrer">includes</a> under Example 5, "include() and the return() statement". If you did this, you could use a ternary condition like:</p> <pre><code>$logged_in = (include('userlogin.php') == TRUE) ? TRUE : FALSE; </code></pre> <p>And then in each protected function have something like:</p> <pre><code>global $logged_in; </code></pre> <p>You are still stuck with an IF clause wrapping the entire function, but at least you have the login status. If you wanted to get rid of the IF inside of the function, you could always make calling the function conditional. Like:</p> <pre><code>$content = ($logged_in == TRUE) ? some_function() : redirect_User(); </code></pre> <p>Then again, I just started learning this stuff 2 months ago and still don't understand classes and objects, so I could be way off base.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload