Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 118f9bc738e28b5079cf04bc3c88b2754f8ae04c9f1e1127d020389c49
- $hash = bin2hex(random_bytes(59/2));
- ##
- ## Get data from database using $_POST variable from <form>
- ##
- if(!empty($_POST['stay_loggedIn'])){
- setcookie('stay_loggedIn', $fetch_data['hash'], strtotime('+14 days'), '/');
- }
- if(!empty($_COOKIE['stay_loggedIn']) && empty($_SESSION['logged_cookie'])){
- ## Set this session variable to run this code only one time
- $_SESSION['logged_cookie'] = 1;
- $hash = $_COOKIE['stay_loggedIn'];
- $logeIn = $conn->prepare("SELECT * FROM users WHERE `hash` = :hash");
- $logeIn->bindValue(':hash', $hash, PDO::PARAM_STR);
- $logeIn->execute();
- $user_data = $logeIn->fetch(PDO::FETCH_ASSOC);
- ##
- ## Set session variables
- ##
- }
- $params = session_get_cookie_params();
- setcookie('stay_loggedIn', '', time() - 3600, $params['path'], $params['domain'], $params['secure'], isset($params['httponly']));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement