<?php

$cre = $_SESSION['username'];
$query = "SELECT * FROM users WHERE  stid='$cre'";
$subject_set = mysqli_query($connection,$query);
$row = mysqli_fetch_array($subject_set);

$user = $row['stid'];

$names = $row['surname'].' '.$row['name'];

if(!isset($_SESSION['username']) || $_SESSION['username']!= $user)
{
    header('Location:logout.php');
}

?>