/** * 设置用户cookie会话 */ public function setCookie() { //set loginName $cookies = Yii::app()->request->cookies[‘username‘]; if ( !($cookies instanceof CHttpCookie) || $cookies->value!=Yii::app()->request->getPost(‘loginName‘) ) { $CookieUserName = new CHttpCookie( ‘username‘, Yii::app()->request->getPost(‘loginName‘) ); $CookieUserName->domain = DOMAIN; $CookieUserName->expire = strtotime( ‘+7 day‘, time() ); Yii::app()->request->cookies->add( ‘username‘, $CookieUserName ); } }
时间: 2024-12-21 05:50:12