Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- logout.php :
- ----------
- <?php
- session_start();
- if (isset($_SESSION['logged']) && $_SESSION['logged'] == 1)
- {
- if(isset($_COOKIE['hamusername']) && isset($_COOKIE['hampassword']))
- {
- setcookie("hamusername", "", time()-60*60*24*100, "/");
- setcookie("hampassword", "", time()-60*60*24*100, "/");
- }
- session_destroy();
- header("Location: index.php");
- }
- else
- header("Location: index.php");
- ?>
- header.php :
- ----------
- if(isset($_COOKIE['hamusername']) && isset($_COOKIE['hampassword']))
- {
- $username = $_COOKIE["hamusername"];
- $password = $_COOKIE["hampassword"];
- $q = $db->prepare("SELECT * FROM `users` WHERE username = ? AND password = ?");
- $q->execute(array($username, $password));
- $is_logged_count = $q->rowCount();
- $row = $q->fetch(PDO::FETCH_OBJ);
- if ($is_logged_count == 1)
- {
- $_SESSION['user_id'] = $row->id;
- $_SESSION['logged'] = 1;
- }
- }
- else
- {
- unset($_COOKIE['hamusername']);
- unset($_COOKIE["hampassword"]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement