device detection ::
When it is desired to determine what type of client is making a request to the server, version 2.0.0 of the CRNRSTN Suite provides a rich set of crnrstn_user :: class object methods for device detection, session persistence of said device detection results, and the reversion of session data back to a state of agnosticism wherein which CRNRSTN can start from "zero" again with respect to meeting the needs of any given use-case scenario.
Note ::
This functionality stands on top of the
Mobile Detect project which has been incorporated into C
RNRSTN Suite v2.0.0.
Mobile Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
Mobile Detect is sponsored by it's developers and community, and they send thanks to the JetBrains team for providing
PHPStorm and
DataGrip licenses for said project.
Example 1 ::
Retrieve a multi data-type response as indication of the existence of conditions which...to a high degree of probability...confirm (or deny) that this is a request originating from a mobile device or tablet computer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
/*
// J5
// Code is Poetry */
require('_crnrstn.root.inc.php');
include_once($CRNRSTN_ROOT . '/_crnrstn.config.inc.php');
//
// PASSING TRUE ALLOWS TABLET COMPUTERS TO BE DETECTED AS MOBILE.
$iAmMobile = $oCRNRSTN_USR->isClientMobile(true);
if($iAmMobile){
//
// MOBILE/TABLET DEVICE EXPERIENCE
echo 'I am mobile!';
}else{
//
// DESKTOP EXPERIENCE
echo 'I am not mobile!';
}
?>
Example 1 Output ::