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

3

10

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 and touch.facebook.com and I want to redirect to different mobiles. and I use WURFL device detection.

So for example m.html5version.com should be delivered to all HTML5 supported devices and m.mobileversion.com should deliver to all other mobiles.

So i need a way to detect device and browser 1st time using any server-side or client-side method. when any user will open the website first time on device then an script should run once it should collect the information about device and browser and should save the information in my existing WURFL database , so next time when any user will come from same device then he will redirect to touch or mobile version of website depending on device.

So only 1st time on 1st device I want to detect device and save the info.

Is there any way to do this?

For example

Android 1.6 doesn't have HTML5 support and still in use. So i want to redirect all Android 1.6 devices to m.mobileversion.com not to touch.mobileversion.com

And in touch version of website I'm using HTML 5 tags like <header>, <footer>, <nav> etc which is not supported Android 1.6. So i want to detect the first device who will access the website from Android 1.6 device and because HTML5 is not supported in 1.6 so user agent should be saved in my database then I when next time any user will open the website in 1.6 it will redirect to lo-fi mobile version automatically, no detection should be needed 2nd time for any device.

Instigation answered 21/5, 2011 at 11:16 Comment(0)
Y
22

see below link, this will perfectly suitable for your need

http://detectmobilebrowser.com

below is one more script :

http://detectmobilebrowsers.mobi

Yabber answered 24/5, 2011 at 10:56 Comment(0)
B
4

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.

Broadspectrum answered 21/5, 2011 at 11:21 Comment(3)
I don't want to detect iPad as a mobile device. I consider iPad as Desktop when I make websiteInstigation
Android 1.6 doesn't have HTML5 support and still in use. So i want to redirect all Android 1.6 devices to m.mobileversion.com not to touch.mobileversion.comInstigation
I'd make the argument that iPhone/Android should be considered such as well, unless your website is an application with UI elements that need to be manipulated. The thing to avoid is flexible width content. If you've a fixed 480-640px content width, the zoom feature is enough for iPhone/Android to browse the site comfortably.Broadspectrum
I
0

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

Incantation answered 24/5, 2011 at 21:8 Comment(1)
But I want to detect one mobile once for all users in the worldInstigation

© 2022 - 2024 — McMap. All rights reserved.