add files
This commit is contained in:
52
session.php
Normal file
52
session.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
include('config/config.php');
|
||||
session_start();
|
||||
|
||||
|
||||
if(isset($_COOKIE['eingeloggt_bleiben']) && !isset($_SESSION["login_user"])) {
|
||||
$user = json_decode($_COOKIE['eingeloggt_bleiben'], true);
|
||||
|
||||
$ses_sql = mysqli_query($db,"select username from admin where username = '$user[username]' and passcode = '$user[password]'");
|
||||
|
||||
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
|
||||
|
||||
$count = mysqli_num_rows($ses_sql);
|
||||
|
||||
if ($count == 1) {
|
||||
$login_session = $user['username'];
|
||||
$_SESSION['login_user'] = $login_session;
|
||||
}else {
|
||||
setcookie('eingeloggt_bleiben', '', 1);
|
||||
}
|
||||
|
||||
|
||||
}else {
|
||||
|
||||
$user_check = $_SESSION['login_user'];
|
||||
|
||||
$ses_sql = mysqli_query($db,"select username from admin where username = '$user_check' ");
|
||||
|
||||
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
|
||||
|
||||
$count = mysqli_num_rows($ses_sql);
|
||||
|
||||
if ($count == 1) {
|
||||
$login_session = $row['username'];
|
||||
$_SESSION['login_user'] = $login_session;
|
||||
}else {
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!isset($_SESSION['login_user'])){
|
||||
header("location:login.php");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user