SAE_web/views/header.php
Loris BALOCCHI 0070f84ea4 🔧 modification du login/register + implémentation du cookie de session
Co-authored-by: Charpentier Juliette <juliette.charpentier1@etu.u-pec.fr>
2024-06-10 23:23:51 +02:00

51 lines
1.4 KiB
PHP

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
if (isset($_COOKIE['userData'])) {
$userDataEncoded = $_COOKIE['userData'];
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
$email = $userData['email'];
$name = $userData['name'];
$familyName = $userData['familyName'];
$role = $userData['role'];
}
?>
<nav class="menu-container">
<!-- burger menu -->
<input type="checkbox" aria-label="Toggle menu" />
<span></span>
<span></span>
<span></span>
<!-- logo -->
<a href="../../../" class="menu-logo">
<img src="https://i.imgur.com/RkmSo9Q.png" alt="Jeux Olympiques - Paris 2024" />
</a>
<!-- menu items -->
<div class="menu">
<ul>
<li>
<a href="/events">
Évènements
</a>
</li>
</ul>
<ul>
<li>
<?php
if (isset($_COOKIE['userData'])) {
echo "<a href='/account/profile'>Mon profil</a>";
} else {
echo "<a href='/account/login'>Connexion</a>";
}
?>
<!-- script php qui vérifie le cookie. Si cookie, propose déconnexion, si pas cookie propose connexion -->
</li>
</ul>
</div>
</nav>