jalpapatel
(Pateljalpamca)
September 26, 2014, 11:44am
1
hii all,
i need to know that i develop one application in yii in which i gave all functionality to see user after login but we need another one funtionality is when user is new and he want to register him self and after that all functionality he can see than what to do?
please reply me in step by step because i am new in yii.
thanks in advance,
jalpa patel
Ankit_Modi
(Ankit Modi)
September 28, 2014, 5:51am
2
Hi Jalpa,
I think you want to create the session for particular user login and data will be fetch the session id wise.
jalpapatel
(Pateljalpamca)
September 29, 2014, 6:32am
3
thanks for give me answer but i can not exactly know the code of session so can you please elaborate the code, so that i can understand it easily…
Ankit_Modi
(Ankit Modi)
September 30, 2014, 7:30am
4
Please read this session tutorial
You can write a User Identity in component folder after login,create the session
for e.g
public function authenticate()
{
$email = $this->username;
$password=md5($this->password);
$criteria = new CDbCriteria();
$criteria->condition = ' t.user_type IN(\'user\',\'blogger\',\'company\') AND t.email= \''.$email.'\' AND t.`password` = \''.$password.'\' AND t.`status` = "1"';
$vkuser = VkUsers::model()->find($criteria);
//$customer=customer::model()->findByAttributes(array('email'=>$email),$criteria);
//p($vkuser);
if($vkuser===null) {
$this->errorCode=self::ERROR_EMAIL_INVALID;
} else if(Yii::app()->getModule('vkuser')->encrypting($this->password)!==$vkuser->password) {
$this->errorCode=self::ERROR_PASSWORD_INVALID;
} else if($vkuser->status>1&&Yii::app()->getModule('vkuser')->loginNotActiv==false) {
$this->errorCode=self::ERROR_STATUS_NOTACTIV;
} else if($vkuser->status==2) {
$this->errorCode=self::ERROR_STATUS_BAN;
} else {
$this->_id = $vkuser->id;
$this->email = $vkuser->email;
$this->username = $vkuser->email;
$this->errorCode= self::ERROR_NONE;
Yii::app()->vkuser->setId($this->_id);
Yii::app()->vkuser->guestName = $vkuser->email;
$userData = $vkuser->attributes;
$userData['fname'] = $vkuser->fname;
Yii::app()->vkuser->setState('vkuser',$userData);
}
return !$this->errorCode;
}
in this code I create the VKuser module and write the session
$userData = $vkuser->attributes;
$userData['fname'] = $vkuser->fname;
Yii::app()->vkuser->setState('vkuser',$userData);
I hope it;s help.