marcovtwout/yii-detectmobilebrowser

There is no license information available for the latest version (1.3.0) of this package.

Handles detecting mobile browsers

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 3

Open Issues: 0

pkg:composer/marcovtwout/yii-detectmobilebrowser

1.3.0 2017-10-23 14:38 UTC

This package is auto-updated.

Last update: 2025-09-26 03:51:25 UTC


README

Handles detecting mobile browsers. Results are stored locally for caching calls within the same request, and stored in a cookie for caching across requests.

Detection regex used from http://detectmobilebrowsers.com/

Requirements

Tested on Yii 1.1.8 - 1.1.14, should work on all versions.

Installation

Install as an application component, in your config:

'components' => array(
   'detectMobileBrowser' => array(
       'class' => 'ext.yii-detectmobilebrowser.XDetectMobileBrowser',
       //'secure' => true,
       //'httpOnly' => true,
    ),
),

Usage

You can get the current user preference like this:

if (Yii::app()->detectMobileBrowser->showMobile) {
    // do something
}

By default it will use the automatically detected value. You can also set the preference yourself like this:

public function actionShowMobile() {
    Yii::app()->detectMobileBrowser->showMobile = true;
    $this->redirect(array('/site/index'));
}