I'm making user activity logging, when I log in user login, have successfully entered database, but when I record user exit activity, user name is not recorded in the database. this my code.
<?php
include '../koneksi.php';
session_start();
$idPengguna = $_SESSION['username'];
$aktifitas = 'Logout';
$tgl = date('Y-m-d H:i:s');
mysql_query("INSERT INTO logfile (nik,aktifitas,tgl_aktif) VALUES ('$idPengguna','$aktifitas','$tgl')")or die(mysql_error());
session_destroy();
header("location:../index.php");
?>