Yii Framework Forum: How Can I Redirect Login Page If Do Not Login In Yii Framework? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How Can I Redirect Login Page If Do Not Login In Yii Framework? Rate Topic: -----

#1 User is offline   sacpv 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 04-December 13

Posted 17 January 2014 - 04:38 AM

I have the actionLogin and create cookie like here :
public function actionLogin()
    {
        $this->layout = 'login';

        $model=new LoginForm;

        if(isset($_POST['LoginForm']))
        {           
            $model->attributes=$_POST['LoginForm'];
            if($model->validate() && $model->login()){          
                $cookie = new CHttpCookie('loginSuccess',$model->username);
                $cookie->expire = 604800;
                var_dump($cookie);exit;
                Yii::app()->request->cookies['loginSuccess'] = $cookie;         
                $this->redirect('/ktbeauty/index.php/categories/index');
            }           
        }

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


And Now I have some controllers which must check to login before access controllers, if not login, it must redirect to login page, how can I work for this ?

thankyou very much
0

#2 User is offline   jcagentzero 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 58
  • Joined: 14-October 11
  • Location:Philippines

Posted 17 January 2014 - 05:09 AM

I already replied to your question
here
Thank you and regards,

jcagentzero

http://www.jundycosmod.com

If you think this post is helpful, please don't hesitate to click + button.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users