Dan
Dan

Reputation: 537

PHP restrict user to directory by session uid/pwd

I have my user mgmt system setup, but how do I re-direct and restrict a user to her/his folder/sub-folders/files according to the $_SESSION['uid']; $_SESSION['pwd']; established when s/he logs in?

I'm using a MySQL-based user mgmt setup.

Upvotes: 0

Views: 221

Answers (2)

Rishabh Goyal
Rishabh Goyal

Reputation: 99

what about this 1st if you dont provide null password

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

2nd if you provide even null password

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

Hope this help you..

Upvotes: 1

Halcyon
Halcyon

Reputation: 57703

You need to know how to map a uid to a folder. If you have the folder location stored in the database somewhere, do a query to find it and do a header("Location: /the/folder"); header-redirect.

Upvotes: 1

Related Questions