Allow access to a URL only by redirect

0

Well ... This may sound strange, but I need to block direct access to a url inside my server, releasing it only when the user is redirected from another specific page.

This would be the scheme I'm trying to imagine:

The user accesses this page: myite.com/home.php?id=xxxxxxx In this page you will have a DOWNLOAD button, and when you click on it the user will be taken to: meusite.com/dl.php?id=xxxxxxx

So, I just want it to have access to * / dl.php if it is * / home.php Is there any way to do this?

    
asked by anonymous 28.11.2018 / 17:35

2 answers

0

If it's just programming, you can use something with the "global variable" $ _SESSION. With the exception of the page that gives permission, put in the others a command similar to this:

$_SESSION['permitir_download'] = 0;

And when the page has the permission:

$_SESSION['permitir_download'] = 1;

On the download page, do something like this:

if ($_SESSION['permitir_download']):
//...Download
     $_SESSION['permitir_download'] = 0;
else:
//...Sem permissão 
     $_SESSION['permitir_download'] = 0;
     die();
endif;

I think it can help.

Hugs.

    
28.11.2018 / 18:02
-1

A very elegant solution is you check the $ _SERVER ['HTTP_REFERER']. Whenever a PHP page is loaded by a GET or POST call, it loads that data with the source address. So you can create behavior to respond to $ _SERVER ['HTTP_REFERER'], according to your needs.

    
28.11.2018 / 19:37