doudui2229 2015-04-02 19:35
浏览 16

COOKIE在PHP中无法识别

Goal: I have two PHP-Files in which i want to store data in a COOKIE set by the site "INDEX.PHP" and pass it over to a site called "LAST.PHP". In the middle there is an external site which will be called in which i have no influence in passing over any variables. The Sourcecodes of the files are the following:

INDEX.PHP

<?php
$cookie_name = "test";
$cookie_value = "It works!";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
?>

LAST.PHP

<?php
echo $_COOKIE['test'];
?>

enter image description here

As you can see i kept it as basic at possible. I simply want to create a COOKIE in the "INDEX.PHP", then i will be redirected to an external site, and this external site is finally redirecting me to "LAST.PHP" in which i just want to output the COOKIE. This is just not working for me right now, can anyone help me out with that? If anyone has suggestions for a more elegant way to transport data from "INDEX.PHP" to "LAST.PHP" that would be much appreciated also, please just keep in mind that i have no influence on the "EXT. SITE". Thank you very much in advance.

  • 写回答

1条回答 默认 最新

  • duanbodai5166 2015-04-02 19:46
    关注

    you should pass your domain after the "/":

    setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/", '.yourdomain.com');
    

    try this out

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效