How to detect mobile device and get user agent info send and save that information to database on server, only once?

不打扰是莪最后的温柔 提交于 2019-11-28 18:57:28

see below link, this will perfectly suitable for your need

http://detectmobilebrowser.com

below is one more script :

http://detectmobilebrowsers.mobi

You might want to look into jQuery's take on this, since it's interesting.

In addition to detecting the browser, they detect browser features:

http://api.jquery.com/jQuery.browser/

http://api.jquery.com/jQuery.support/

Also, keep in mind that some mobile users don't want to be redirected to the mobile-optimized device. I, for one, positively hate it when a site detects my iPad as a mobile device and sends me (without any possibility to override it) to a sloppy mobile site that I wouldn't even want to browse with an iPhone.

iOS and Android devices, in general, will happily work with the standard site if it's coded properly. And other mobile phones are quickly dying.

As far as only detecting and saving the data once, you can set a cookie to record the fact that you've already done the detection. Then the next time a page is loaded, check to see if the cookie exists -- if it doesn't, then call your detection function and record to the database. If you do find the cookie, then you know you've already collected the data and you can skip doing it again.

http://www.quirksmode.org/js/cookies.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!