hi guys how can i destroy session after some minutes (example 30min), i would really appriciate if someone can help me through out of this,
here is my code im using for login :
checkLogin :
<?php
// checkLogin.php
session_start(); // Start a new session
require('db.php'); // Holds all of our database connection information
// Get the data passed from the form
$username = $_POST['user'];
$password = $_POST['pass'];
// Do some basic sanitizing
$static_salt='asdfasdfqwertyuiop123ABC_some_static_salt_string';
$username = stripslashes($username);
$password = stripslashes($password);
$password=hash('sha512', $password . $static_salt . $username);
$sql = "select * from users where user = '$username' and pass = '$password'";
$result = mysql_query($sql) or die ( mysql_error() );
$count = 0;
while ($line = mysql_fetch_assoc($result)) {
$count++;
}
if ($count == 1) {
$_SESSION['loggedIn'] = "true";
header("Location: index.php"); // This is wherever you want to redirect the user to
} else {
$_SESSION['loggedIn'] = "false";
header("Location: deshtoi.php"); // Wherever you want the user to go when they fail the login
}
?>
Login.php
<div class="login-form">
<form action="checkLogin.php" method="post">
<input class="fusha" placeholder="Llogaria" type="text" name="user">
<input class="fusha" placeholder="Fjalekalimi" type="password" name="pass">
<input class="fusha" style="width:272px;" type="submit" value="Kycu"/>
</form>
index.php
<?php session_start();
if ($_SESSION['loggedIn'] != "true") {
print('<script>window.location = "login.php"</script>');
}
?>