Sharing session across multiple domains on same server in PHP

GDG

I need to implement a solution for one of my project, where I have multiple domains + multiple sub-domains and they all need to share the same session. All domains and sub-domains would be pointed to the single application which is connected to the single database.

Means if user logged in from any of the domain will be able to visit secure pages of other domains of the application. User may change domain via following a link or via opening a new tab in the browser.

I have gone through some articles and found some below mentioned solutions:-

  1. Session in Database - What if other user from same network with same user agent hits?

  2. iFrame message passing - I heard at somewhere, that iFrame renders on document load and, then checking session after showing some page content will annoy the user.

  3. CURL request with CURLOPT_COOKIEFILE & CURLOPT_COOKIEJAR - I have played with this and it is working fine, but don't know if it is secure and not performance killer.

  4. Single Sign On (SSO) - I need some R&D to implement this and it would be the last option.

Please suggest what to do?

v2solutions.com

Just to verify I am not wrong, you need to share user session across all your applications.

As rightly said above, you may use 4 of the options above. However, I would like to focus on first option which is putting session in DB and would like to suggest another option as keeping sessions in shared directory or server.

  1. Sessions in DB - The answer to your question (What if other user from same network with same user agent hits?) is you will have different session id's value to uniquely identify each row in Table. So, no need to worry about it. But the disadvantage is, each time DB connection would be required and a query would be fired, when session is initialized i.e. for every single page.

  2. Sessions in shared directory/server - Configure all your applications in a such a manner that all applications store session at shared location. Shared location can either be a directory or a secured server. This can easily achieved by using session_set_save_handler.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

How to share the same config across multiple angular apps

来自分类Dev

How to enforce same nuget package version across multiple c# projects?

来自分类Dev

What is the better practice for sharing variables across Node.js modules

来自分类Dev

使用$ _SESSION的PHP SESSION变量

来自分类Dev

How to configure a single flask application to handle multiple domains?

来自分类Dev

Use one instance of Yourls URL shortner with multiple domains

来自分类Dev

PHP $ _SESSION停止执行

来自分类Dev

PHP $_SESSION stops execution

来自分类Dev

PHP Session not loading

来自分类Dev

PHP session_start();

来自分类Dev

PHP Session劫持安全

来自分类Dev

PHP SESSION变量麻烦

来自分类Dev

Implementing Dependency injection across multiple solutions

来自分类Dev

在分配?_SESSION php之前取消设置?_SESSION

来自分类Dev

SAS batch jobs: executing multiple scripts through the same local server connection

来自分类Dev

Two Azure Mobile Services (.NET backend) sharing the same Database

来自分类Dev

跨子域的PHP $ _SESSION

来自分类Dev

PHP:取消设置数组$ _SESSION

来自分类Dev

PHP SESSION中的多维数组

来自分类Dev

PHP条件session_start

来自分类Dev

PHP session_start()的用法

来自分类Dev

PHP for $ _SESSION变量的循环迭代

来自分类Dev

无法设置PHP $ _SESSION变量

来自分类Dev

php5 $ _SESSION安全

来自分类Dev

从计数变量创建 php $_SESSION

来自分类Dev

php session 没有被破坏

来自分类Dev

Php = $_SESSION => 无法显示消息

来自分类Dev

PHP AJAX 未收到 SESSION

来自分类Dev

CONSTANT 中的 PHP $_SESSION 变量