L
L
Leonid Fedotov2014-08-21 19:31:08
PHP
Leonid Fedotov, 2014-08-21 19:31:08

How to allow access to directories through .htaccess if there is a certain variable in $_SESSION?

Let's say I have several directories with mixed files that I want to close from prying eyes. And only I want to get access to them, and give out a 403 error to everyone else. Authorization to the interface occurs through the PHP admin form and the $_SESSION['authed'] = true variable is created; Is it possible to somehow open access to directories and the contents in them through .htaccess if a variable is defined? I heard that most likely this is not implemented. PHP itself is already processed after .htaccess is executed. Or is there a way without friendship with .htacess? Maybe there are some solutions with cookies? It is very important that the load on the server is as low as possible, so processing all requests through a PHP script is not welcome.
And yes, I'm supposed to log in from different IP addresses.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WebSpider, 2014-08-21
@iLeonidze

In short, no. In any case, some intermediate logic will be required, which will climb into the PHP session and decide whether to give files or not. For example, it can be Nginx + Lua module, node.js or any other software (for example, its own layer on Python / Tornado or something like that)

V
Vitaly Nevzorov, 2015-03-25
@f1_real

Read about RewriteMap, and check by IP, cookies, session filename (if sessions are in files)...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question