当前位置:网站首页>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";
边栏推荐
- Myopia: take off or match glasses? These problems must be understood clearly first
- Please be prepared to lose your job at any time within 3 years?
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
- The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
- 架构实战营 - 第 6 期 毕业总结
- Using optimistic lock and pessimistic lock in MySQL to realize distributed lock
- 《天天数学》连载56:二月二十五日
- Is it safe to open an account with flush?
- Expression of request header in different countries and languages
- MongoDB 的安装和基本操作
猜你喜欢
![App mobile terminal test [3] ADB command](/img/f1/4bff6e66b77d0f867bf7237019e982.png)
App mobile terminal test [3] ADB command

ThreeJS 第二篇:顶点概念、几何体结构

Détails du contrôle de la congestion TCP | 3. Espace de conception

One article takes you to understand machine learning

【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事

MongoDB 的安装和基本操作

The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)

【Proteus仿真】74HC595+74LS154驱动显示16X16点阵

跟我学企业级flutter项目:简化框架demo参考

Break through 1million, sword finger 2million!
随机推荐
Why does the std:: string operation perform poorly- Why do std::string operations perform poorly?
Unity项目优化案例一
8 tips for effective performance evaluation
Expression of request header in different countries and languages
SVN使用规范
Detailed explanation of four modes of distributed transaction (Seata)
Interviewer: how does the JVM allocate and recycle off heap memory
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword
PHP中register_globals参数设置
[redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
[system safety] 43 PowerShell malicious code detection series (5) automatic extraction of ten thousand words from abstract syntax tree
The mixlab editing team is recruiting teammates~~
面试官:JVM如何分配和回收堆外内存
Deep understanding of grouping sets statements in SQL
Project -- high concurrency memory pool
Characteristic polynomial and constant coefficient homogeneous linear recurrence
利用MySQL中的乐观锁和悲观锁实现分布式锁
“用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画