当前位置:网站首页>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";
边栏推荐
- TCP擁塞控制詳解 | 3. 設計空間
- Nifi from introduction to practice (nanny level tutorial) - flow
- Leetcode binary search tree
- 初试scikit-learn库
- Function introduction of JMeter thread group
- Page dynamics [2]keyframes
- Expression of request header in different countries and languages
- June to - -------
- Visual SLAM algorithms: a survey from 2010 to 2016
- Principles of several common IO models
猜你喜欢
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Stm32f103c8t6 firmware library lighting
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
[statement] about searching sogk1997 and finding many web crawler results
NSQ源码安装运行过程
Colab works with Google cloud disk
Redis installation under windows and Linux systems
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
随机推荐
Eleven requirements for test management post
First!! Is lancet hungry? Official documents
SVN使用规范
nifi从入门到实战(保姆级教程)——flow
[web security] - [SQL injection] - error detection injection
Hibernate的缓存机制/会话级缓存机制
Threejs Part 2: vertex concept, geometry structure
Nifi from introduction to practice (nanny level tutorial) - flow
Rk3399 platform development series explanation (WiFi) 5.54. What is WiFi wireless LAN
Function introduction of JMeter thread group
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
NSQ源码安装运行过程
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Cocos Creator 2. X automatic packaging (build + compile)
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
ASEMI整流桥UMB10F参数,UMB10F规格,UMB10F封装
Colab works with Google cloud disk
Page dynamics [2]keyframes
Thinking about telecommuting under the background of normalization of epidemic | community essay solicitation
Q2 encryption market investment and financing report in 2022: gamefi becomes an investment keyword