TrinityTuts Tips

Detect is your website is access from Mobile and Device

This is very simple and useful tip to detect that your user is using Android or iOs device to log in to your website in CakePHP 3 it is even easier

CakePHP 3 device detection 

$isMobile = $this->request->is('mobile');
$isAndroid = stripos($this->request->header('User-Agent'), 'Android');
$isIPhone = stripos($this->request->header('User-Agent'), 'iPhone');
$isIPad = stripos($this->request->header('User-Agent'), 'iPad');

Core PHP

$iPhone  = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad    = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");

Hope this tip help you.

If this code help you plz like and share this with other