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条)

报告相同问题?