Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $token = $_SESSION['token'] = md5(uniqid(mt_rand(),true));
- if(Yii::app()->user->hasFlash('error')){
- ?>
- <div class="flashMessage">
- <?php echo Yii::app()->user->getFlash('error') ?>
- </div>
- <?php
- }
- ?>
- <input type="hidden" name="token" value="<?php echo $token ?>"/>
- //Rest of the form
- // collect user input data
- if(isset($_POST['LoginForm'])){
- //Check if the token matches
- if($_POST['token'] == $_SESSION['token']){
- $model->attributes=$_POST['LoginForm'];
- // validate user input and redirect to the previous page if valid
- if($model->validate() && $model->login())
- $this->redirect(Yii::app()->user->returnUrl);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement