Jump to content

Logout.php


kbeaulieu

Recommended Posts

I am trying to get my logout.php file to work. I want it to destroy the session and update the timeout header in my database. I can't seem to get it to add the timeout to the database. Can anyone help.

 

<?php
//connect to database
$con = mysql_connect ("localhost", "root", "");
//error handling
if(!$con)
{
die('Could not connect: ' . mysql.error());
}
//get things entered from user
mysql_select_db("mydb", $con);

session_start();

$sessid = session_id();
mysql_query("UPDATE sessions SET timeout=current_timestamp WHERE sessionid='$sessid'");
// setcookie(session_name(),",1);
session_destroy();

mysql_close($con);

$URL="login.html"; 
header('Location:' . $URL);
?>

Link to comment
https://forums.phpfreaks.com/topic/194944-logoutphp/
Share on other sites

make it throw an error is mysql is incorrect...

 

in other words, change this:

mysql_query("UPDATE sessions SET timeout=current_timestamp WHERE sessionid='$sessid'");

to this:

mysql_query("UPDATE sessions SET timeout=current_timestamp WHERE sessionid='$sessid'") or die('Error:'.mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/194944-logoutphp/#findComment-1024939
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.