当前位置:网站首页>PHP secondary domain name session sharing scheme
PHP secondary domain name session sharing scheme
2022-07-03 16:21:00 【Brother Xing plays with the clouds】
Generally speaking, websites will have master stations and sub stations , For example, the domain name is linuxidc.com, So in general linuxidc.com and www.linuxidc.com It will be the main station , And like bbs.linuxidc.com Will exist as a sub station of the Forum .
And pay attention to , Although the domain name is generally set dns When parsing , Will be linuxidc.com and www.linuxidc.com It is set to point to the home page, although the effect looks the same . But these two are really different domain names , That is, if it is the default , These two domain names cookie Of domain Think differently .
In general , If the website has user login function , We generally hope that no matter what kind of secondary domain name , They all maintain this login status .
therefore , In order to solve this secondary domain name session Sharing issues , The following scheme is recommended :
<?phpini_set("session.cookie_domain",'linuxidc.com');// notes : This sentence must be placed in session_start() Before session_start();
It should be noted that :
1、ini_set("session.cookie_domain",'linuxidc.com'); Must be on session_start(); Before .
2、 domain name linuxidc.com It must match the domain name actually accessed by the browser .
In fact, it's very simple , That is, the primary domain name and the secondary domain name domain Set as the primary domain name , In this way... Can be achieved session Shared access between different secondary domain names .
Ps. stay PHP Of CI In the frame , If you want to realize its own Session Classes can be shared in different secondary domain names , It's in /application/config/config.php In file , Make the following settings :
$config['cookie_domain'] = "linuxidc.com";
边栏推荐
- Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
- pycharm错Error updating package list: connect timed out
- 面试官:JVM如何分配和回收堆外内存
- Colab works with Google cloud disk
- [statement] about searching sogk1997 and finding many web crawler results
- From the 18th line to the first line, the new story of the network security industry
- 8 cool visual charts to quickly write the visual analysis report that the boss likes to see
- "Everyday Mathematics" serial 56: February 25
- 【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
猜你喜欢

Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN

First knowledge of database

Mb10m-asemi rectifier bridge mb10m

Visual SLAM algorithms: a survey from 2010 to 2016

The mixlab editing team is recruiting teammates~~
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix

嵌入式开发:避免开源软件的7个理由

How to thicken the brush in the graphical interface

Mongodb installation and basic operation

Myopia: take off or match glasses? These problems must be understood clearly first
随机推荐
How to thicken the brush in the graphical interface
ThreeJS 第二篇:顶点概念、几何体结构
面试官:JVM如何分配和回收堆外内存
Caching mechanism of Hibernate / session level caching mechanism
[combinatorics] combinatorial identity (sum of combinatorial identity products 1 | sum of products 1 proof | sum of combinatorial identity products 2 | sum of products 2 proof)
Is it safe to open an account with flush?
Cocos Creator 2. X automatic packaging (build + compile)
1287. Elements that appear more than 25% in an ordered array
[200 opencv routines] 217 Mouse interaction to obtain polygon area (ROI)
"Remake Apple product UI with Android" (3) - elegant statistical chart
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
How can technology managers quickly improve leadership?
[combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
Explore Netease's large-scale automated testing solutions see here see here
Unreal_DataTable 实现Id自增与设置RowName
Embedded development: seven reasons to avoid open source software
MongoDB 的安装和基本操作
Page dynamics [2]keyframes