简体   繁体   English

理解并修复https和http之间丢失的php会话

[英]Understand & fix php session lost between https and http

I have developed a mvc site from scratch and locally it works, but what a surprise ! 我从零开始开发了一个mvc网站,并在当地工作,但真是一个惊喜! Trying the site uploaded to my hosting it doesn't work. 尝试上传到我的主机的网站不起作用。

The login sequence is the following: Every page checks if you are loged (http) and redirect to login page (https) if you don't. 登录顺序如下:每个页面检查您是否被挂起(http)并重定向到登录页面(https),如果不这样做。 Always you will be redirected to login page. 始终您将被重定向到登录页面。

After some research, I have discovered the reason: php session is lost between https and http. 经过一番研究,我发现了原因:https和http之间的php会话丢失了。

I don't understand why works locally and remotely not, but I think due php local settings set php sesssion identifier as PHPESSID for http & https and remote settings not. 我不明白为什么本地和远程工作没有,但我认为由于php本地设置将php sesssion标识符设置为http和https和远程设置的PHPESSID不。

Thinking about the trouble, I understand I can fix the issue passing the session identifier from https to http or making the whole site https rewriting the urls as follow: 考虑到这个问题,我知道我可以解决将会话标识符从https传递到http或使整个站点https重写URL的问题,如下所示:

intranet.mysite.com/anypage/ intranet.mysite.com/anypage/

Hosting shared ssl https://server.subdomain/~user/public_html/intranet/anypage/ 托管共享ssl https://server.subdomain/~user/public_html/intranet/anypage/

Additional information 附加信息

the page is hosted under hostgator. 该页面托管在hostgator下。 The url paths are 网址是

site intranet.mydomain.com site intranet.mydomain.com

ssl shared access https://gatorxxx.hostgator.com/~user/intranet ssl共享访问https://gatorxxx.hostgator.com/~user/intranet

how I can make session works between urls ? 我如何在URL之间进行会话?

thanks. 谢谢。

If I understand correctly you host the SSL page on a different domain? 如果我理解正确,您在其他域上托管SSL页面? The PHP session cookie is lost then, because the cookie is bound by subdomain (or domain, whichever the cookiedomain is set to). 然后PHP会话cookie丢失,因为cookie由子域(或域,无论cookiedomain设置为哪个)绑定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM