0

Like the title says, is it possible to detect whether a particular page is being accessed via a web browser as opposed to an HTTP request? I'm aware that accessing via a web browser is performing an HTTP request, so I'm curious if it's at all possible to differentiate.

I ask because I'd like a certain page to only be accessible via my own application and it should not be browsed to directly.

1
  • Then add a header sent from your application and/or use authentication? Commented Mar 23, 2014 at 15:16

2 Answers 2

1

Try to use get_browser and check for isMobileDevice field. you can check it using if condition and retrict the access of that page if request comes from web browser.

It might help only, of course, if the path to browscap.ini is set up in php.ini. If not, you can use php classes like https://github.com/garetjax/phpbrowscap

Sign up to request clarification or add additional context in comments.

Comments

0

If it's a publicly accessible URL, there's no way to fundamentally differentiate between "your app" and "anybody else". It's only an HTTP request, whichever way you access it. If you set the right headers, there's no way to differentiate one request from another identical one. If you want to limit access to "your app" only, set some specific secret authentication headers which only "your app" knows. However, if "your app" is Javascript in a webpage, anyone will be able to inspect and see those "secret" headers.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.