Onbekend |
|
Ik denk dat je het best sessions én cookies kunt doen, net zoals nemesiskoen al zegt.
Alleen ik zou het iets anders doen:
check.php
<?PHP
if(IsSet($_COOKIE['isAdmin'])){
$adminArray = explode('|+|',$_COOKIE['isAdmin']);
if((count($adminArray) == 2) && ($adminArray[0] == $sUsr) && ($adminArray[1] == MD5($sPass))){
$_SESSION['loggedIn'] = true;
setCookie('isAdmin',$sUsr.'|+|'.MD5($sPass), (time()+(3600*24*30)),"/");
}
}
?>
<?PHP if(IsSet($_COOKIE['isAdmin'])){ $adminArray = explode('|+|',$_COOKIE['isAdmin']); if((count($adminArray) == 2) && ($adminArray[0] == $sUsr) && ($adminArray[1] == MD5($sPass))){ $_SESSION['loggedIn'] = true; } } ?>
config.php
<?PHP
session_Start();
$sUsr = 'Username';
$sPass = 'Pass';
require 'check.php';
?>
<?PHP $sUsr = 'Username'; $sPass = 'Pass'; require 'check.php'; ?>
login.php
<?PHP
require 'config.php';
if(!$_SESSION['loggedIn']){
if(!IsSet($_POST['logIn'])){
// Echo Form
}
else{
if(($_POST['UserName'] == $sUsr) && ($_POST['PassWord'] == $sPass)){
setCookie('isAdmin',$sUsr.'|+|'.MD5($sPass), (time()+(3600*24*30)),"/");
$_SESSION['loggedIn'] = true;
header('Location: admin.php');
exit;
}
}
}
else{
echo 'U bent al ingelogd...';
}
?>
<?PHP require 'config.php'; if(!$_SESSION['loggedIn']){ if(!IsSet($_POST['logIn'])){ // Echo Form } else{ if(($_POST['UserName'] == $sUsr) && ($_POST['PassWord'] == $sPass)){ $_SESSION['loggedIn'] = true; header('Location: admin.php'); } } } else{ echo 'U bent al ingelogd...'; } ?>
admin.php
<?PHP
require 'config.php';
if($_SESSION['loggedIn']){
// Admin Gedeelte
}
else{
header("Location: login.php");
exit;
}
?>
<?PHP require 'config.php'; if($_SESSION['loggedIn']){ // Admin Gedeelte } else{ header("Location: login.php"); } ?>
Hoop dat dit een beetje is wat je bedoelt en dat het ook werkt (niet getest). |