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

后端 未结 3 1719
不思量自难忘°
不思量自难忘° 2020-12-13 22:38

Is there any script to check user agent then send and save that information to database on server?

I\'m making mobile website with 2 versions like m.facebook.com

3条回答
  •  有刺的猬
    2020-12-13 22:58

    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

提交回复
热议问题