Yii Framework Forum: Redirect ke loginUrl - Yii Framework Forum

Jump to content

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

Redirect ke loginUrl Rate Topic: -----

Poll: Polling belajar Yii !!! (3 member(s) have cast votes)

Mudah atau susah belajar Yii ????

  1. Susah Sekali (1 votes [33.33%])

    Percentage of vote: 33.33%

  2. Susah (0 votes [0.00%])

    Percentage of vote: 0.00%

  3. pusing .... (0 votes [0.00%])

    Percentage of vote: 0.00%

  4. Mudah (0 votes [0.00%])

    Percentage of vote: 0.00%

  5. Mudah Sekali (2 votes [66.67%])

    Percentage of vote: 66.67%

Vote Guests cannot vote

#1 User is offline   omarxp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 12-February 10
  • Location:Yogyakarta

Posted 22 February 2010 - 02:25 AM

para master, mw tanya!!

cara melakukan redirect ke halaman login bila user blm login, gmna??

misal index.php?r=server/index = halaman setelah login
dan index.php?r=login/index = halaman untuk login.

bila kita langsung akses halaman index.php?r=server/index tanpa login maka langsung di redirect ke halaman index.php?r=login/index.


ada yang bisa share??????
0

#2 User is offline   nasrul 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 98
  • Joined: 14-April 09
  • Location:Sorowako - Indonesia

Posted 24 February 2010 - 01:38 AM

serverController.php
<?php
class SiteController extends CController
{
   ...
	public function actionIndex()
	{
		if (!Yii::app()->user->IsGuest){   //jika diakses oleh selain guest
			//render view server/index
                        $this->render('index');   
		}else{                             //kalau tidak
                        //redirect ke index.php?r=login/index 
			$this->redirect(array('login/index'));  
		}
	}
   ...
}


Kalau controller dikaitkan dengan model yang mengandung CRUD, kita dapat menyesuaikan behaviour accessRules()-nya.
1

#3 User is offline   omarxp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 12-February 10
  • Location:Yogyakarta

Posted 24 February 2010 - 02:16 AM

sip, udah bisa, makasih.
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