35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
include('koneksi.php');
|
|
|
|
session_start();
|
|
|
|
if (!$_SESSION['ebookft'] || !$_COOKIE['ebookft']) {
|
|
header('Location: login.php');
|
|
} else {
|
|
list($uid, $upw) = ($_COOKIE['ebookft'] ? explode(".", $_COOKIE['ebookft']) : explode(".", $_SESSION['ebookft']));
|
|
|
|
if (empty($uid) || empty($upw)) {
|
|
setcookie('ebookft', "", (time() - 2592000), "/", "", 0);
|
|
$_SESSION['ebookft'] = "";
|
|
|
|
session_destroy();
|
|
|
|
return (false);
|
|
}
|
|
|
|
$sql = "SELECT * FROM user WHERE username='".$uid."' AND password='".$upw."'";
|
|
$query = mysqli_query($koneksi, $sql);
|
|
$user = mysqli_fetch_array($query);
|
|
// echo $user['username'];
|
|
// echo $uid;
|
|
if ($user['username'] == $uid) {
|
|
|
|
define("LOGIN", true);
|
|
define("USERNAME", $user['username']);
|
|
} else {
|
|
define("LOGIN", false);
|
|
define("USERNAME", false);
|
|
header('Location: login.php');
|
|
}
|
|
}
|
|
?>
|