How do I use a session for my login screen?
<p>I am creating a webshop and I have the login working but I ran into a problem. I need to use sessions in order to display and hide certain pages. It's a login screen for the backend of my webshop so it makes sense that it should be secured and hidden from people who aren't allowed to access the backend. I know that I need to start a session at the top of the pagebut then what? I searched Google but I can't find a solution wich I can apply to my code.</p>

<pre><code>&lt;?php
session_start();

*my information*

// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
// Check connection
if ($conn-&gt;connect_error) {
die("Connection failed: " . $conn-&gt;connect_error);
}

if(isset($_POST['submit'])) {
$uname = $_POST['username'];
$wwoord = $_POST['wachtwoord'];
$query = "SELECT * FROM Medewerkers WHERE medewerker_username='$uname' &amp;&amp; medewerker_password='$wwoord'";
$result = mysqli_query($conn, $query);

if($result) {
    $_SESSION['ingelogd'] = true;
    echo"U bent ingelogd!";
    header("location: index.php");

} else {
    echo "Inloggegevens incorrect.";
}
}
?&gt;

&lt;html lang="en"&gt;&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Admin panel&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="tables.css"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="content"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="index.php"&gt;Admin panel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="Medewerkersoverzicht.php"&gt;Medewerkersoverzicht&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="addMedewerker.php"&gt;Medewerkers toevoegen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="Klantenoverzicht.php"&gt;Klantenoverzicht&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="Productoverzicht.php"&gt;Productoverzicht&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="addProduct.php"&gt;Product toevoegen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="reparatieOverzicht.php"&gt;Reparatieoverzicht&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="contactoverzicht.php"&gt;Contactoverzicht&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Admin login&lt;/h1&gt;
&lt;form role="form" method="post" action="index.php" class="contactForm"&gt;
    &lt;table&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;label for="username"&gt;Username&lt;/label&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="username" class="" id="username"&gt;      &lt;br&gt;&lt;br&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;label for="wachtwoord"&gt;Wachtwoord&lt;/label&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="password" name="wachtwoord" class=""    id="wachtwoord"&gt;&lt;br&gt;&lt;br&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;button type="submit" name="submit" class="button"&gt;Inloggen&lt;/button&gt;&lt;br&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/html&gt;
</code></pre>