Browser Validation

Hello,

I recently inherited a Yii based project at work and I have been tasked with adding several new features. This is the first time I have worked with Yii and I seem to have gotten myself stuck.

One of the features that I need to add is a browser validation page. The idea of this page is if you attempt to use the app with an unsupported browser you will be directed to a page that tells you that performance might be less than optimal you then have the option of following a link to a supported browsers page or continuing anyway.

This is the code I used to determine which page to load initially:


if($this->browserCheck()){						

			if (!Yii::app()->user->isGuest)

			{

			    $this->redirect(array('confirm'));

			}

	    

			    $model=new LoginForm;

	    

			    if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

			    {

				    echo CActiveForm::validate($model);

				    Yii::app()->end();

			    }

	    

			    if(isset($_POST['LoginForm']))

			    {

				    $model->attributes=$_POST['LoginForm'];

				    if ($model->validate() && $model->login())

				    {

					    $this->redirect(array('confirm'));

				    }

			    }

			    header("Content-type: text/html", true, 203);

			    $this->render('login',array('model'=>$model));

		}else{

			$model = new LoginForm;

			$this->render('browser',array('model'=>$model));

			

		}

My problem is if a user has an unsupported browser and they get directed to the page that tells them so, I dont know how to implement a "continue anyway button" that would render the login page for them.

Am I going about this totally wrong? Is there a better solution? Any help would be appreciated.

Thanks

Maybe simply create a link and add a flag to $_GET saying continue=true. If you render the same action again, then let the user with the not supported browser pass along… :)

Thanks you for sharing

Thanks, I’ll try this.

Ok I got it.

I added this function to my SiteController:


public function actionContinueAnyway(){

		$this->continueAnyway = true;

		$this->actionLogin();

	}



then I modified my login conditional statement to be true if the browser was accepted or if continueAnyway was set to true.

then in my "browser fail" view I added:


  <?php echo CHtml::link('Continue Anyway',array('Site/ContinueAnyway')); ?>

Thanks again to jrn for the inspiration.