How restrict access to specific PHP page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
6tr6tr
Forum Newbie
Posts: 4
Joined: Mon Jun 08, 2009 4:50 pm

How restrict access to specific PHP page?

Post by 6tr6tr »

Is there a way to restrict access to a PHP page to only other pages from within the same domain? Is HTTP_REFERER the only way?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How restrict access to specific PHP page?

Post by requinix »

There is no way.

HTTP_REFERER won't always be set, and when it is you have no way of knowing that it wasn't faked.
6tr6tr
Forum Newbie
Posts: 4
Joined: Mon Jun 08, 2009 4:50 pm

Re: How restrict access to specific PHP page?

Post by 6tr6tr »

tasairis wrote:There is no way.

HTTP_REFERER won't always be set, and when it is you have no way of knowing that it wasn't faked.
What about when they restrict access to certain folders? Does that work the same way?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How restrict access to specific PHP page?

Post by Benjamin »

You can use cookies or sessions to verify that they have already viewed pages on your site.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How restrict access to specific PHP page?

Post by requinix »

6tr6tr wrote:What about when they restrict access to certain folders? Does that work the same way?
Depends what you're talking about. Either it's a different mechanism (comparing apples to oranges) or their security isn't as strong as they think/want you to believe.

astions is right: you can make sure they've visited your site, and even within the last X minutes, but not that they visited immediately and directly before going to that one page. They could open two windows/tabs: visit your site in one, then visit a different site in another that has a link to this page of yours.
Post Reply