dqxz96998 2019-03-05 18:59
浏览 67
已采纳

不同子域(w / PHP)之间的SSO / Auth?

I was wondering if I could use PHP to do SSO between two different sub-domains. (ex: parappawithfries.com and *.parappawithfries.com). My config is not like it should be, because I use cloudflare to point my subs to a different 000webhost website. I know I should just use infinityfree, but I don't get https:// and subdomains. Lots of issues, but it it could be fixed, that'd be great. ANYWAY, I was wondering if I could do something like this in HTML.

<script src="https://parappawithfries.com/user.js"></script>

and in user.js (in the NON sub-domain) needs to set a cookie with the user's PHPSESSID copied over by JS by basically printing it as a variable. Can I do that with JS, AJAX, jQuery, or any way possible without using anything other than PHP, HTML, JS, AJAX, or jQuery?

Ok, ok lemme edit im sorry. parappawithfries.com points to parappawithfries.000webhostapp.com. It's subdomains don't point to a folder in parappawithfries.000webhostapp.com. it points to a DIFFERENT 000webhost site. Not a folder in parappawithfries.000webhostapp.com.

Oh yeah, btw, here is an example: https://imgur.com/a/giBwTwp

I need to edit... AGAIN (this is getting tiring)

I switched hosting from 000webhost to infinityfree and I got subdomains working. Time to see if it will work now...

  • 写回答

2条回答 默认 最新

  • dougan6402 2019-03-05 19:26
    关注

    In PHP if you setcookie() with a $domain parameter (e.g. parappawithfries.com), that cookie can be accessed by that domain and any subdomains.

    https://secure.php.net/manual/en/function.setcookie.php

    From there, you can make sure all your sites are set up to used a singular Memcached server, and they should all be able to share the same session(s).

    Have a look at the below link for some details on setting this up.

    https://www.digitalocean.com/community/tutorials/how-to-share-php-sessions-on-multiple-memcached-servers-on-ubuntu-14-04

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我这个代码哪里有问题 acm 平台上显示错误 90%,我自己运行好像没什么问题
  • ¥50 C#编程中使用printDocument类实现文字排版打印问题
  • ¥15 找会编程的帅哥美女 可以用MATLAB里面的simulink编程,用Keil5编也可以。
  • ¥15 已知隐函数其中一个变量τ的具体值,求另一个变量
  • ¥15 r语言Hurst指数
  • ¥15 Acrn IVSHMEM doorbell问题
  • ¥15 yolov5中的val测试集训练时数量变小问题
  • ¥15 MPLS/VPN实验中MPLS的配置问题
  • ¥15 materialstudio氢键计算问题
  • ¥15 echarts图表制作