Hkm Sadek Hossain Hkm Sadek Hossain - 1 year ago 69
PHP Question

logging out is not working in live server godaddy

I have written a few lines of code in php that helps a user to logout. It works in localhost but in live server the system doesn't logout the users. Could you please help whats wrong with the code?


setcookie($cookie_name, $cookie_value, time() - (3600), "/");
// 86400 = 1 day
echo "<script>window.location='$url'</script>";


Answer Source

Try this on your live server:

  // session_start() should be at the to of your file

  $_SESSION['uid'] = '';

  $cookie_name = "user";

  if(session_destroy()) {
    $url = $base_url . 'index.php';

    setcookie($cookie_name, $cookie_value, time() - (3600), "/");

    echo "<script>alert($_COOKIE[$cookie_name])</script>";

    //echo "<script>window.location='$url'</script>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download