user 'Logout' is not working in my website after migrating to new server. before it was good.

here is the code in member.php

// Log-out part
if (isset($_GET['logout'])){
       $pass = "";
       setcookie ("pwd","",time()-3600);
       $pwd = "";
       setcookie("name","",time()-3600);
       $name="";
       setcookie("type","",time()-3600);
       $type="";
       header("Location: member.php");
}

Looking for help
Thank you

Recommended Answers

All 3 Replies

are you getting error : header already sent error???

OR

setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.
according to this,you might get error if any output is set.Please check you are using it properly.

Make sure that you aren't sending any output to the browser before the setcookie() function is called. ob_start() should stop the "output before setcookie()" error, but it might not be implemented correctly.

You can do that without setting a cookie by:

<?php
session_start();
session_destroy();
//redirect the user to any page
header("Location:index.php");
//Than Finish!!!
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.