网址相同,但www会话不同 [英] Same URL without www different session

查看:68
本文介绍了网址相同,但www会话不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下问题(我知道你们中的许多人可能已经或曾经有过),但仍然找不到适合我的解释,或者至少没有适当的解决方法。

I have the following issue (that i know many of you probably have or had) but still i haven't found an explanation anywhere that satisfies me, or at least a proper solution.

在我创建的任何站点的会话脚本中,如果用户使用www.domain.com浏览该域并登录,但随后在另一个选项卡中,他进入了同一页面而没有万维网。 (domain.com)该会话尚未开始。

In the session script of any of the sites that i make, if the user goes through the domain using www.domain.com and logs in, but then in a different tab he goes to the same page without the www. (domain.com) The session hasn't been started in that one.

我在stackoverflow上发现了这两个问题,但是它们都没有提供真正的解决方案,或者至少没有解释这种现象的原因。

i have found this two questions on stackoverflow but none of them offers a real solution or at least an explanation of why this behavior.

与url的with-www和没有-www

PHP会话登录对于带www和不带www的URL是否有所不同?

好吧,这重定向和规则在我的情况下不起作用。

Ok to go the point, This redirections and rules doesn't work in my case.

为什么?因为我正在与使用cURL的付款提供商合作,以检索我发送给他们的一些数据,并且当他们将响应发送回给我时,他们使用的是我必须提供给他们的默认URL。目前,他们将地址设置为www。但是,如果我的一个用户使用不带www。的域访问网站的特定页面怎么办?当我从提供商那里得到响应时,它将转到www.site.com,并且该用户没有登录。

Why? because i'm working with a payment provider that uses cURL to retrieve some data i send to them, and when they send the response back to me, they use a default URL wich i have to give to them. currently they set up the address as www. but what if one of my users goes to an especific page of the site using the domain without the www.? When i get the response from the provider it goes to www.site.com and the user there is not logged. and no actions can be applied.

对此有任何帮助吗?

感谢
的欢呼。

Thanks Cheers.

推荐答案

如所述 http://www.php.net/manual/zh/function.setcookie.php


可用于较低域名(例如 example.com)的Cookie将被
可用于较高子域(例如 www.example.com

Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'



所以就做

So just do

session_set_cookie_params(0, '/', 'yourdomain.com');

没有 www

这篇关于网址相同,但www会话不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆