Skip to content

Instantly share code, notes, and snippets.

@cdeutsch
Last active December 28, 2015 11:59
Show Gist options
  • Select an option

  • Save cdeutsch/7497163 to your computer and use it in GitHub Desktop.

Select an option

Save cdeutsch/7497163 to your computer and use it in GitHub Desktop.
Redirect if browser is mobile
public function actionMobileLogin()
{
$this->layout = 'mobile';
Yii::app()->user->setState('loginType', 'mobile');
$this->actionLogin(true);
}
public function actionLogin($skipMobileCheck = false)
{
if (!$skipMobileCheck)
{
if (preg_match("/(spectrumplayground)/i", $_SERVER["HTTP_USER_AGENT"]))
{
$this->redirect('/mobileLogin/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment