title: Check User's login in moodle
body: <p>I'm writing custom.php file to my moodle and i have question. </p>
  
  <ol>
  <li><p>How to check if user is logged in and how to check his login ?</p>
  
  <p>2.How to make my page avaliable only for logged students ?</p></li>
  </ol>
  
  <p>Some Code i already wrote:</p>
  
  <pre><code>// The number of lines in front of config file determine the // hierarchy of files. 
  require_once(dirname(dirname(__FILE__)).'/../../config.php');    
  
  $PAGE-&gt;set_context(get_system_context());
  $PAGE-&gt;set_pagelayout('admin');
  $PAGE-&gt;set_title("Badanie Umiejętności - eszkolenia24.pl");
  $PAGE-&gt;set_heading("Blank page");
  $PAGE-&gt;set_url($CFG-&gt;wwwroot.'/blank_page.php');
  
  echo $OUTPUT-&gt;header();
  ?&gt;
  
  &lt;h1&gt;Some Text&lt;/h1&gt;
  
  &lt;div class="row"&gt;
    &lt;div class="col-lg-12 col-md-12 col-xs-12 col-sm-12"&gt;
  &lt;/div&gt;
  
  &lt;?php
  echo $OUTPUT-&gt;footer();
  ?&gt;
  </code></pre>
  
  <p>Answer 1: require_login();</p>