脚本宝典收集整理的这篇文章主要介绍了php – 如何在yii中注册后登录用户,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
在UserController中,我创建了actionRegister以允许用户创建新的帐户,如果用户成功保存到db,我想为此用户执行登录.继承我的代码:
public function actionRegister() { $model=new User; if(isset($_POST['User'])) { $model->attributes=$_POST['User']; if($model->save()){ $identITy=new UserIdentity($model->email,$model->password); $identity->authenticate(); Yii::app()->user->login($identity); $this->redirect(array('view','id'=>$model->id)); } } $this->render('register',array('model'=>$model)); }
提前感谢您在这件事上给我的任何帮助.
以上是脚本宝典为你收集整理的php – 如何在yii中注册后登录用户全部内容,希望文章能够帮你解决php – 如何在yii中注册后登录用户所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。