thinkphp: Multiple projects share the same session problem

Source: Internet
Author: User

Using the ThinkPHP3.1.3 version of the session, multiple projects at the same time debugging will make one-dimensional array of the session is not enough, resulting in a project login background, the B project will not have to login backstage to enter the background operation.

The problem is that they all call the same session file SESS_D55A5F55DB022FB119FC38193C4CECAC. I don't know how to define how this file is named. However, I found a way to solve multiple projects that share the same session but do not conflict with each other. The principle of this method is to change the session into a two-dimensional array. The specific action is to add the session prefix in the configuration file (preferably named sess+ project name)

1     // Session prefix 2     ' Session_prefix '= ' and'mysessa',

Then using the two-dimensional session

Take value

1 $_session[c ('session_prefix') ['uid'];

The corresponding exit login

1      Public function Loginout () {2         $_session[c ('session_prefix')]=null ; 3         $this->redirect (group_name.' /login/index ' ); 4     }

thinkphp: Multiple projects share the same session problem

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.