当前位置:网站首页>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";
边栏推荐
- Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
- Threejs Part 2: vertex concept, geometry structure
- Mixlab编辑团队招募队友啦~~
- MongoDB 的安装和基本操作
- Expression of request header in different countries and languages
- Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
- [system safety] 43 PowerShell malicious code detection series (5) automatic extraction of ten thousand words from abstract syntax tree
- 0214-27100 a day with little fluctuation
- [solved] access denied for user 'root' @ 'localhost' (using password: yes)
- PHP中register_globals参数设置
猜你喜欢

Record windows10 installation tensorflow-gpu2.4.0

About text selection in web pages and counting the length of selected text

8个酷炫可视化图表,快速写出老板爱看的可视化分析报告

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

From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing

Uploads labs range (with source code analysis) (under update)

Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14

Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword

NSQ源码安装运行过程

嵌入式开发:避免开源软件的7个理由
随机推荐
远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
8 tips for effective performance evaluation
无心剑中译泰戈尔《漂鸟集(1~10)》
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
pyinstaller不是内部或外部命令,也不是可运行的程序 或批处理文件
Mongodb installation and basic operation
Nifi from introduction to practice (nanny level tutorial) - flow
Hibernate的缓存机制/会话级缓存机制
如何在本机搭建SVN服务器
0214-27100 a day with little fluctuation
One article takes you to understand machine learning
First knowledge of database
Caching mechanism of Hibernate / session level caching mechanism
App mobile terminal test [4] APK operation
TCP拥塞控制详解 | 3. 设计空间
QT串口ui设计和解决显示中文乱码
Mongodb installation and basic operation
Stm32f103c8t6 firmware library lighting
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
Visual SLAM algorithms: a survey from 2010 to 2016