5. Analyze the session and cookie, and distinguish the session and cookie before and after;
Remember logon status
In this way, you do not need to enter the user name and password again when you log on to the website again.
It is the cookie of the browser that remembers the status.
Form creation:
<tr> <td align="right"> <?php echo $form->checkBox($user_login, 'rememberMe'); ?> </td> <td> <?php echo $form->labelEx($user_login, 'rememberMe'); ?> </td> </tr>
Modify model:
View cookie and session information results:
Major User Logon:
/** Log out of the system */function actionlogout () {// Delete the session information // yii: APP ()-> session-> clear (); // Delete the sessiion variable information in the memory // yii: APP ()-> session-> destroy (); // Delete the server's session file // Delete the session and cookie together. Otherwise, you cannot exit yii: APP ()-> User-> logout (); $ this-> redirect ('/');}
In this case, there will be a problem:
You can set the session prefix in the background.
{Public function Init () {// custom background default controller $ this-> defaultcontroller = "Index "; // this method is called when the module is being created // you may place code here to customize the module or the application // import the module-level models and components $ this-> setimport (Array ('houtai. models. * ', 'houtai. components. * ',); // set the session name prefix information for the background logon administrator yii: APP ()-> setcomponents (Array ('user' => array ('statekeypr Efix '=> 'houtai', 'loginurl' =>'./index. php? R = houtai/manager/login ',)));}
Figure:
stateKeyPrefix
How are the parameters?
In this way:
Yii MVC user registration and User Logon (5)