mysql - PHP session doesn't update when user logs ou -
i have website in php uses mysql create accounts , allow users log in , log out. working fine. when users logs in, changes enum value, "loggedin" 1 meaning logged in. when log out, doesnt change 0. have logout hyperlinking logout php , code of logout php.
<?php // create connection include_once 'credentials.php'; $conn = new mysqli($db_hostname, $db_username, $db_password, $db_database); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); }else{ session_start(); session_destroy(); $sql = ("update users set loggedin = '0' id = '$userid'"); mysqli_query($conn, $sql); header("location: ../index.php"); exit; } ?>
but doesnt seem working. also, on logged in one, when user logs in first time, loggedin status changed in mysql website not show unless user logs out, in again.
you have check update query in mysql application (eg: phpmyadmin) making sure query runs well. try remove ( )
of line $sql = ("update users set loggedin = '0' id = '$userid'");
$sql = "update users set loggedin = '0' id = '$userid'";
last, make sure path of header location right. success :)
Comments
Post a Comment