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
After summary, the main solutions to the problem of cross-domain session are as follows:
The first case: If there is no .htaccess file in your directory, that is, if the url is not pseudo-static, then you add:
ini_set('session.cookie_domain',".domain.com");//跨域访问Session
in the first line of conf/config.php. If this is the case You have enabled debugging, it may work! 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:
This method works regardless of whether debugging is turned on or not!
For more related articles on solutions to the cross-domain problem of sessions implemented by the ThinkPHP framework, please pay attention to the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
