-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcookie.php
45 lines (39 loc) · 1.2 KB
/
cookie.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
session_start();
include 'header.php';
if(isset($_SESSION['id']))
{
header('Location: index.php');
}
else
{
if(isset($_COOKIE['id']) AND isset($_COOKIE['email']) AND isset($_COOKIE['confirmcookie']))
{
$id = htmlspecialchars($_COOKIE['id']);
$email = htmlspecialchars($_COOKIE['email']);
$confirmcookie = htmlspecialchars($_COOKIE['confirmcookie']);
$requser = $bdd->prepare('SELECT * FROM utilisateurs WHERE id = ? AND email = ? AND confirmcookie = ?');
$requser->execute(array($id, $email, $confirmcookie));
$userexist = $requser->rowCount();
if($userexist == 1)
{
$userinfo = $requser->fetch();
$_SESSION['id'] = $userinfo['id'];
$_SESSION['nom'] = $userinfo['nom'];
$_SESSION['email'] = $userinfo['email'];
$_SESSION['admin'] = $userinfo['admin'];
$_SESSION['auteur_actu'] = $userinfo['auteur_actu'];
$_SESSION['auteur_doc'] = $userinfo['auteur_doc'];
header('Location: index.php');
}
else
{
header('Location: index.php');
}
}
else
{
header('Location: index.php');
}
}
?>