我怎么能携带饼干在PHP中的多个子 [英] How can I carry cookies in php to multiple subdomain

查看:139
本文介绍了我怎么能携带饼干在PHP中的多个子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要随身携带一些饼干值不同的子域像

I want to carry some cookies value to different subdomains like

blog.mydomain.com,profile.mydomain.com,stats.mydomain.com等。

现在我用下面code设置Cookie

Right now I am using below code to set cookies

的setcookie('VAR_NAME','var_value,空,/,.mydomain.com来');

有了这个code,设置 blog.mydomain.com 可在 mydomain.com Cookie,但不能在其他子域( profile.mydomain.com,stats.mydomain.com等。

With this code, cookies set on blog.mydomain.com available on mydomain.com but not on other subdomain (profile.mydomain.com , stats.mydomain.com, etc.)

请让我知道,什么是错我的code。

Please, let me know, whats wrong with my code .

推荐答案

尝试:

$res = setcookie('var_name', 'var_value', null, "/", '.mydomain.com' );
var_dump($res); exit;

输出应为 TRUE ,如果你看到这意味着输出存在调用这个函数,你之前开始发送内容后不能设置cookies

the output should be TRUE, if you see false it means output exists prior to calling this function and you can't set cookies after beginning sending content

这篇关于我怎么能携带饼干在PHP中的多个子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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