1. in the middle of the loginForm of YII, there is a login method used to set the time for remembering the username: {code ...} as shown above, if I set $ duration $ this-& amp; gt; rememberMe? 36002410: 0; 10 days, that is, I set it to 10 days. Whether the cookie is valid for 10 days, or... 1. In the loginForm of YII, there is a login method used to set the time for remembering the User name:
public function login() { if($this->_identity===null) { $this->_identity=new UserIdentity($this->username,$this->password); $this->_identity->authenticate(); } if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { $duration=$this->rememberMe ? 3600*24*10 : 0; // 10 days Yii::app()->user->login($this->_identity,$duration); return true; } else return false; }}
As shown above, if I set $ duration = $ this-> rememberMe? 36002410: 0; // 10 days, that is, I set it to 10 days. Is the cookie validity period set to 10 days, or is the cookie and session validity period set to 10 days?
I want to set the validity period of the session to 10 days. I don't know where to set it.
Another problem is that if the cookie is 10 days, the session is only half an hour. When I log on with a cookie the next day, does PHP generate a session based on the cookie.
Or does php automatically generate a session and write the sessionID back to the cookie center?
Reply content:
1. In the loginForm of YII, there is a login method used to set the time to remember the User name:
public function login() { if($this->_identity===null) { $this->_identity=new UserIdentity($this->username,$this->password); $this->_identity->authenticate(); } if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { $duration=$this->rememberMe ? 3600*24*10 : 0; // 10 days Yii::app()->user->login($this->_identity,$duration); return true; } else return false; }}
As shown above, if I set $ duration = $ this-> rememberMe? 36002410: 0; // 10 days, that is, I set it to 10 days. Is the cookie validity period set to 10 days, or is the cookie and session validity period set to 10 days?
I want to set the validity period of the session to 10 days. I don't know where to set it.
Another problem is that if the cookie is 10 days, the session is only half an hour. When I log on with a cookie the next day, does PHP generate a session based on the cookie.
Or does php automatically generate a session and write the sessionID back to the cookie center?
The session exists on the server,
Cookies exist on the client, that is, your computer,
When your browser is closed, the session will become invalid,
The session validity period is controlled by server settings.