0

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

4
Contributors
3
Replies
26
Views
4 Years
Discussion Span
Last Post by Saleh_1
0

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.

Edited by IIM

0

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!!!
?>

Edited by Saleh_1

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.