The session is divided into two main parts:
One, is the session data, the data is stored by default in the server's TMP file, php.ini can be changed.
Two, which is the session id,session Id that marks the session data, that session File name, session ID is randomly generated, so to ensure uniqueness and randomness, to ensure the security of the session. In general, if the lifetime of the session is not set, the session ID is stored in memory, the ID is automatically logged off after the browser is closed, and a session ID is re-registered after the page is re-requested. If the client does not disable cookies, the cookie plays the role of storing the session ID and session lifetime when the session is started.
Two different domain sites, want to use the same session, is involved in the session cross-domain problem!
There are three ways to solve this problem:
1. The following settings are provided at the beginning of the PHP page (to be preceded by any output and before session_start ())
Ini_set (' Session.cookie_path ', '/');
Ini_set (' Session.cookie_domain ', '. mydomain.com ');
Ini_set (' Session.cookie_lifetime ', ' 1800 ');
2. Set in php.ini
Session.cookie_path =/
Session.cookie_domain =. mydomain.com
Session.cookie_lifetime = 1800
3. Call the function at the beginning of the PHP page (condition same as 1)
Session_set_cookie_params (1800, '/', '. mydomain.com ');
Experimental results:
One
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5C/9F/wKiom1UeTs-izDBxAALIDsdA6tc978.jpg "title=" C1d62fe8-e673-4576-9637-1b7f962f806d.png "alt=" Wkiom1uets-izdbxaalidsda6tc978.jpg "/>
Two
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/9F/wKiom1UeTdORaMiEAALAOwJsBXg975.jpg "style=" float: none; "title=" De95145d-bbd2-450e-abea-4f772628cfcc.png "alt=" Wkiom1uetdoramieaalaowjsbxg975.jpg "/>
As they are but the session_id is the same, so the session data can also be shared, thus solving the simplest single sign-on.
PHP website Single Sign-on-volume one (cross two level domain name)