This article mainly introduced the THINKPHP framework realization session Cross-domain problem solution method, needs the friend can refer to the next
Thinkphp's session cross-domain issues many developers have encountered!
In fact, whether it is thinkphp or PHP itself, in solving the cross-domain problem of the session need to set Session.cookie_domain.
In thinkphp, the configuration file needs to be modified conf/config.php
In the first line, add:
Ini_set (' Session.cookie_domain ', ". domain.com");//cross-domain Access session
After summing up, there are several ways to solve the problem of cross-domain of the session:
The first case: If your directory does not have a. htaccess this file, that is, the URL pseudo-static is not taken, then you add the first line in conf/config.php:
Ini_set (' Session.cookie_domain ', ". domain.com");//cross-domain Access session
If you turn on debugging, it may be used! But it turns off debugging, it probably doesn't work!
The second case: if you have a. htaccess file in your directory, then you add the first line in the root directory, index.php:
<?php ini_set (' Session.cookie_domain ', ". domain.com");//cross-domain access session//define thinkphp frame path define (' Think_path ', '/ thinkphp/');//define the project name and path define (' App_name ', ' Www ');d efine (' App_path ', '. '); /Load Frame entry file require (Think_path. " /thinkphp.php ");//Instantiate a website application instance App::run ();? >
This method works regardless of opening or commissioning!
The above is the whole content of this article, thank you for reading, more relevant content please pay attention to topic.alibabacloud.com!