a.php判断登录程序中加入
//假设你使用login函数进行登录检验if (login($_POST['user_name'], $_POST['pwd']))//登录成功 
{
  session_start();
  $_SESSION['user_name'] = $_POST['user_name];
}
b.php 加入
session_start();
if (isset($_SESSION['user_name'])
{
     显示内容
}
else
{
    header("Location: a.php");
}

解决方案 »

  1.   

    我改了之后现在点击后退,会出现如下错误:
    警告: 网页已经过期 您申请的网页是用表单中提交的信息创建的。该网页已失效。由于有安全预警功能,Internet Explorer 不会自动再次提交您的信息。 要重新提交信息并查看该网页,请单击刷新按钮。
    要什么修改 
      

  2.   

    代码开头加
    session_cache_limiter("private");
    session_start();
      

  3.   

    能否解释一下,我找不到session_cache_liniter()函数
      

  4.   

    这样做是为了安全,你还要看提交前的内容?
    session_cache_limiter
    (PHP 4 >= 4.0.3)session_cache_limiter -- Get and/or set the current cache limiter
    Description
    string session_cache_limiter ( [string cache_limiter])
    session_cache_limiter() returns the name of the current cache limiter. If cache_limiter is specified, the name of the current cache limiter is changed to the new value. The cache limiter defines which cache control HTTP headers are sent to the client. These headers determine the rules by which the page content may be cached by the client and intermediate proxies. Setting the cache limiter to nocache disallows any client/proxy caching. A value of public permits caching by proxies and the client, whereas private disallows caching by proxies and permits the client to cache the contents. In private mode, the Expire header sent to the client may cause confusion for some browsers, including Mozilla. You can avoid this problem by using private_no_expire mode. The expire header is never sent to the client in this mode. 注: private_no_expire was added in PHP 4.2.0. The cache limiter is reset to the default value stored in session.cache_limiter at request startup time. Thus, you need to call session_cache_limiter() for every request (and before session_start() is called). 
      

  5.   

    session_cache_limiter
    不是
    session_cache_liniter