say i store some data associated with a session id in a database . how do i delete the data when the session is timeout in php(i do not want to fill my file sever with all junk data.)?
is there any call back function to call in php ?
say i store some data associated with a session id in a database . how do i delete the data when the session is timeout in php(i do not want to fill my file sever with all junk data.)?
is there any call back function to call in php ?
You can write php script
<?php
session_start();
$query = "DELETE FROM session_data WHERE session_id = '{$_SESSION['session_id']}'";
// in case you want to read this from ajax as json response
echo mysq_query($query) ? "true" : "false";
session_destroy();
?>
and access this script with ajax on uload event with JQuery
$(window).unload(function() {
$.get('destroy_session.php', null, function(data, status) {
// ignore result
});
});