哪个最适合浏览器检测:PHP 或 Javascript?

发布于 2025-01-04 09:18:31 字数 145 浏览 2 评论 0原文

我想做的很简单:在登录过程中,如果系统检测到其他人使用相同的凭据签名,则通知用户当前登录的 IP 地址和浏览器。这就是为什么要使用 PHP 或 Javascript 将浏览器名称记录到数据库中登录期间。您知道用于此目的的任何好的脚本吗?

请给出链接或邮政编码。

What I want to do is simple: during signin process, if system detects that someone else signed with same credentials, to notify user about ip addresses and browsers that currently signed in. That's why want to use PHP or Javascript to record browser name into database during signin. Do you know any good script for this purpose?

Please give link or post code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一个人的旅程 2025-01-11 09:18:31

Java脚本最适合浏览器检测,因为在php中,有关浏览器的可用信息来自http用户代理标头,因为这是可以定制的,我们无法确定浏览器。但如果我们使用 javascript,我们会得到正确的结果。你可以使用jquery内置函数来检查浏览器及其版本。

示例:显示浏览器信息。

<!DOCTYPE html>
<html>
<head>
  <style>
  p { color:green; font-weight:bolder; margin:3px 0 0 10px; }
  div { color:blue; margin-left:20px; font-size:14px; }
  span { color:red; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<p>Browser info:</p>

<script>
    jQuery.each(jQuery.browser, function(i, val) {
      $("<div>" + i + " : <span>" + val + "</span>")
                .appendTo( document.body );
    });</script>

</body>
</html>


Browser info:
mozilla : true
version : 10.0

检查文档
http://api.jquery.com/jQuery.browser/

Java script is best for browser detection , because in php the information available about browsers come from the http user agent header, as this can be customized we cannot make sure about the browser. But if we use javascript we get the correct result. U can use the jquery built in function to check the browser and its version .

Example: Show the browser info.

<!DOCTYPE html>
<html>
<head>
  <style>
  p { color:green; font-weight:bolder; margin:3px 0 0 10px; }
  div { color:blue; margin-left:20px; font-size:14px; }
  span { color:red; }
  </style>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<p>Browser info:</p>

<script>
    jQuery.each(jQuery.browser, function(i, val) {
      $("<div>" + i + " : <span>" + val + "</span>")
                .appendTo( document.body );
    });</script>

</body>
</html>


Browser info:
mozilla : true
version : 10.0

Check the documentation
http://api.jquery.com/jQuery.browser/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文