【发布时间】:2011-08-09 14:54:02
【问题描述】:
我的项目使用 htaccess 文件来限制对服务器资源的访问。通过 HTTP 身份验证授予访问权限。
我想离开 HTTP 身份验证并使用类似 php-session 的登录身份验证来检查访问。
我想要做的可以简单地在如下脚本中完成:
<?php
session_start()
if ( !isset($_SESSION['user']) ) {
header('location : /login.php');
exit;
}
//...also we could use url rewriting to redirect all urls pointing to static resource through
// a script that will deliver its content or redirect to the login form depending on
// identification status
使用 php 处理动态页面不是问题,但是如何使用 apache 中的 cookie 传递的会话 id 访问静态资源?
我在 apache 中看到了与基于 cookie 的重定向相关的问题,但没有一个涉及基于 cookie 传递的 sessionId 来识别用户的问题。
【问题讨论】: