Help me about this function!

That command just gets the useragent. The useragent can be set by the usere to anything they like and so cannot be relied on to distinguish between browsers. I have all the browsers on my computer set to use the same useragent.

The only legitimate use for that field is for gathering statistics where the inaccuracy in the results doesn’t matter. It should not be used for any other purpose.

If you want to stop a logged in account being swapped between browsers then having something on the server to record that they are logged in and using a session or cookie passed to the browser to also keep track will always properly detect if they try to log in from another browser because the server will show they are logged in but the appropriate session or cookie will not exist.