Thinkphp Framework for session cross-domain problems

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

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.