NogDog;10932570 wrote:The location header may be preempting your cookie headers. If that's the case, you may want to use a META tag redirect instead. (I'm not positive about this, but it might be worth a try if no one else comes up with a better suggestion.)
He's right. I use meta tags to bypass this problem.
PHP Manual wrote:Common Pitfalls:
Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);
So sort of thing about it as if it were this forum. When you log in you get sent to a intermediary page. Then after a few seconds, you get transferred to the page.
So all you need to do is this.
1/ change your header location to to your intermediary page
2/ put meta location tags within the <head> of that page to transfer to your view page again.
eg.
your script (viewpage.php)
<?php
if ($_GET['logout'] == "yes") {
setcookie ("name", "", time() - 60*60*24*30*12, "/", ".livescore-bg.net");
//time()-1year instead of just your 41 days, ensures the cookie is removed.
setcookie ("pass", "", time() - 60*60*24*30*12, "/", ".livescore-bg.net");
session_start();
session_unset();
session_destroy();
$_SESSION = array();
header("Location: http://livescore-bg.net/logouttest.php");
} else {
//here goes some code for displaying the page for a logged user
}
?>
intermediary page (logouttest.php):
<?php
//Do something if you want
?>
<html>
<head>
<meta http-equiv="refresh" content="5;url=http://livescore-bg.net" />
</head>
<body>
</body>
</html>
break it down:
<meta http-equiv="refresh" content="5;url=http://livescore-bg.net" />
http-equiv="refresh"
-> Action
content="5;url=tester1.php"
-> Show the page for 5 seconds then,
-> goto this page "http://livescore-bg.net"
After this page, if you test for the cookies, they will be unset.
NogDog was right and it works. Hope this helps.