当前位置:网站首页>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";
边栏推荐
- QT串口ui设计和解决显示中文乱码
- Explore Netease's large-scale automated testing solutions see here see here
- Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
- Please be prepared to lose your job at any time within 3 years?
- Stm32f103c8t6 firmware library lighting
- Getting started with Message Oriented Middleware
- 用通达信炒股开户安全吗?
- Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
- Jmeter线程组功能介绍
- 【LeetCode】94. Middle order traversal of binary tree
猜你喜欢

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

"Remake Apple product UI with Android" (2) -- silky Appstore card transition animation

Multithread 02 thread join

Function introduction of JMeter thread group

Getting started with Message Oriented Middleware

First knowledge of database
![[system safety] 43 PowerShell malicious code detection series (5) automatic extraction of ten thousand words from abstract syntax tree](/img/cd/00954b9c592c253d42e6a3b8298999.jpg)
[system safety] 43 PowerShell malicious code detection series (5) automatic extraction of ten thousand words from abstract syntax tree

uploads-labs靶场(附源码分析)(更新中)
![[list to map] collectors Tomap syntax sharing (case practice)](/img/ac/e02deb1cb237806d357a88fb812852.jpg)
[list to map] collectors Tomap syntax sharing (case practice)

跟我学企业级flutter项目:简化框架demo参考
随机推荐
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
探索Cassandra的去中心化分布式架构
Mongodb installation and basic operation
How to use AAB to APK and APK to AAB of Google play apps on the shelves
嵌入式开发:避免开源软件的7个理由
SVN使用规范
特征多项式与常系数齐次线性递推
Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
Leetcode binary search tree
Extraction of the same pointcut
首发!!lancet饿了么官方文档
Develop team OKR in the way of "crowdfunding"
相同切入点的抽取
nifi从入门到实战(保姆级教程)——flow
[list to map] collectors Tomap syntax sharing (case practice)
记一次jar包冲突解决过程
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
“用Android复刻Apple产品UI”(2)——丝滑的AppStore卡片转场动画
用同花顺炒股开户安全吗?
如何在本机搭建SVN服务器