PHP通过会话uid/pwd限制用户访问目录


PHP restrict user to directory by session uid/pwd

我有我的用户mgmt系统设置,但是我如何根据登录时建立的$_SESSION['uid']; $_SESSION['pwd'];重定向和限制用户到她/他的文件夹/子文件夹/文件?

我正在使用基于mysql的用户mgmt设置。

您需要知道如何将uid映射到文件夹。如果你有文件夹的位置存储在数据库的某个地方,做一个查询找到它,并做一个header("Location: /the/folder");头重定向。

这个怎么样第一,如果你不提供空密码

if($_SESSION['uid']=="")&&( $_SESSION['pwd']==""))
{
header('Location: http://www.example.com/');//redirect where ever you want
}

第二个如果你提供空密码

if($_SESSION['uid']=="")&&( $_SESSION['pwd']!=""))
{
header('Location: http://www.example.com/');//redirect where ever you want
}