marcovtwout / yii-detectmobilebrowser
此软件包最新版本(1.3.0)没有可用的许可信息。
处理检测移动浏览器
1.3.0
2017-10-23 14:38 UTC
This package is auto-updated.
Last update: 2024-09-26 01:28:12 UTC
README
处理检测移动浏览器。结果将存储在本地,用于同一请求内的缓存调用,并在跨请求时存储在cookie中。
使用的检测正则表达式来自 http://detectmobilebrowsers.com/
要求
在Yii 1.1.8 - 1.1.14上进行了测试,应适用于所有版本。
安装
作为应用程序组件安装,在你的配置中
'components' => array( 'detectMobileBrowser' => array( 'class' => 'ext.yii-detectmobilebrowser.XDetectMobileBrowser', //'secure' => true, //'httpOnly' => true, ), ),
使用方法
你可以这样获取当前用户的偏好
if (Yii::app()->detectMobileBrowser->showMobile) { // do something }
默认情况下,它将使用自动检测的值。你也可以自己设置偏好,如下所示
public function actionShowMobile() { Yii::app()->detectMobileBrowser->showMobile = true; $this->redirect(array('/site/index')); }