Questions about YIISession and Cookie validity period and relationship between cookie and session

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.