Durumda birileri nasıl PHP bir köprü yapabilir, bilir ...
<?php
echo( '<a href="index.php">Log-out</a>' );
?>
değil sadece cekti ilk sayfaya gitmek için değil, aynı zamanda çerezleri kaldırmak?
Teşekkürler!
index.php?logout=true gibi bağlantı içinde bir parametreyi göndermek sizin index.php bu parametre kontrol ve set ise, çerezleri silin:
http://php.net/manual/de/function.setcookie.php
Eğer geçmişte bir şey için bir çerez "ömür boyu" (sona) (veya tamamen dışarı bırakın) ayarlarsanız, bu (yardım bulmak için "php çerezi silmek" için bir Google araması yapmak) sonraki pageload kaldırılmış olacaktır. Gerekirse, bir sayfa yeniden kuvvet.
Ayrıca kullanıcının oturumu yok etmek isteyebilirsiniz.
Sen (yani geçmişte sona erecek onları ayarlar) ve daha sonra yönlendirir bütün çerezleri siler başka bir sayfa yapabilirsiniz index.php:
// page: clear.php
<?php
session_start();
$_SESSION = array();
session_destroy();
setcookie('cookie1', '', strtotime('-2 days'));
setcookie('cookie2', '', strtotime('-2 days'));
// etc.
header('Location: index.php');
exit();
Ben genellikle tarafından reçete yöntemi kullanmak manual:
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
?>
Geriye kalan tek şey, header('Location: index.php');
Navigasyon menüsünde:
<a href="logout.php">Log out</a>
In logout.php,
<?php
// kill the session
header('Location: index.php');
exit();
Oturumu öldürmek için, PHP kılavuzda session_destroy() de bir örneğini görüyoruz.