ThinkPHP framework implements session cross-domain issues

不言
Release: 2023-03-30 13:14:02
Original
2000 people have browsed it

This article mainly introduces the solution to the session cross-domain problem in the ThinkPHP framework. Friends who need it can refer to

ThinkPHP's session cross-domain problem has been encountered by many developers!
In fact, whether it is ThinkPHP or PHP itself, session.cookie_domain needs to be set when solving session cross-domain problems.
In ThinkPHP, you need to modify the configuration file conf/config.php
Add in the first line:

ini_set('session.cookie_domain', ".domain.com");//跨域访问Session
Copy after login

After summary, the main solutions to the problem of session cross-domain are as follows: Type:

The first situation: If there is no .htaccess file in your directory, that is, if the URL is not pseudo-static, then you add: ## to the first line of conf/config.php #

ini_set('session.cookie_domain',".domain.com");//跨域访问Session
Copy after login

This may work if you enable debugging! But if debugging is turned off, it may not work!

Second case: If there is a .htaccess file in your directory, then you add in the root directory, the first line of index.php:

Copy after login
This method does not matter whether it is enabled or not. It works for debugging!


The above is the entire content of this article. Thank you for reading. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

thinkPHP5.0 framework overall architecture overview [application, module, MVC, driver, behavior, namespace, etc.]

thinkPHP framework implements the method of generating barcodes

The above is the detailed content of ThinkPHP framework implements session cross-domain issues. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!