Giriş yaptığında önbelleğe almak değil sayfaları yapmak için nasıl

2 Cevap php

Im using wamp server for my php scripts. And Im having difficulties on the logout code. Every time I click on the logout link and then click on the back button on web browser it still shows the page which can only be access by the user who is logged in. I have this code at the beginning of the index.php which is called by the log out link to destroy the session:

<?php
session_start();
session_destroy();


?>

Ve ben kullanıcı sayfanın başında bu var:

<? 
session_start();
if(!session_is_registered(myusername)){
header("location:login.php");
}
?>

Kullanıcının oturumu sonra userpage hala erişim olabilir neden bilmiyorum.

As an another note will disabling the back-button for this can solve the problem Please help.

2 Cevap

(Html ​​ile kullanarak eğer) önbelleğe tarayıcınızı durdurmak için sayfaları html veya php dosyasının sizin kafa etiketinde kodları bu iki satırı ekleyin

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="expires" CONTENT="0">

Bunun yerine, bu gibi önbelleklenebilecek olmamak için sayfasını ayarlamak gerekir:

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Thu, 15 Apr 2010 20:00:00 GMT");

Bu şekilde, istemci yeniden isteği sayfa sunucudan yeni bir "çıkış yapmış" versiyonu alıyor, geri isabet ne zaman.

Bir başka not, onları en iyi şekilde deneyim kırmak internet% 99.999 gibi davranmaya değil, siteniz için, belli bir şekilde çalışmak için müşterinin butonları ile değil ever karışıklık bekliyoruz.