Jump to content

can php always parse most browser values with get_browser()?


Recommended Posts

It works for me.

But I am testing localhost how a visitor counter has to work properly.

I add visitors to a database.table based on cookie. If there is no cookie I use ip number AND browser type (get_browser)

But there are many users that hide their ip or username. So my question is : can a website visitor hide the browser type by sending an empty value or is the get_browser() output then sending a fake / other browser name? get_browser parses then fake values of other browsers.

Is that possible?


Link to comment
Share on other sites

If you're relying on the user-agent header, then yes that can be altered or removed completely.  Any data that the user sends is prone to being altered.  Unless you're passing a custom value to get_browser all it does is try to make sense of the user-agent header based on the information that it has.  The user-agent header is supposed to contain information about the browser but, like most other headers, it can be changed or removed.  It's not required for an HTTP request.

Link to comment
Share on other sites

  • 2 weeks later...

I still have  questions open for the visitor counter I am making.

I now base a visit on a cookie, together with either an ip number or a get_browser() value;  by placing it in the database table, distinguishing it in different time units.


But what would you suggest to do when none of the above params is available? 

Is there an alternative?

Can I use the headers for counting visits?

And how is that done?

Link to comment
Share on other sites

You could use localStorage in Javascript to track people, or there are other client-side methods to do the same thing.

Look into browser fingerprinting.  There is a lot of information exposed by the browser through Javascript which can be used to uniquely identify a particular computer.  That's one of the ways that something like Google Analytics would use to distinguish individual visits.

Link to comment
Share on other sites

How unique it is depends on what you've done to your computer.


Using that, my browser happens to be unique among the ~300,000 or so they've tested.  A browser would not be unique if someone was using the default installation of IE/Edge on the most popular version of Windows.  They probably see a lot of those.  If any options which control web behavior are changed, or plugins are installed, or a bunch of fonts are installed, or any number of other things, it gets more and more unique.

Is it as unique as uniqid() ?

No, uniqid is supposed to be guaranteed to be unique (or, at least, it will take a long, long time before you get a collision).  The total number of values possible for uniqid is greater than the total number of possible browser configurations.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...