duangua5742 2014-09-01 12:35
浏览 50
已采纳

跨多个页面存储PHP会话

I have setup a PHP session to capture the CAMPAIGN and CLICKID variables that are passed to the site within a URL - i.e. domain.com/index.php?&clickid=test1&campaign=test1. I am achieving this using he code below :

<?php
session_start();
$_SESSION["campaign"] = $_GET['campaign'];
$_SESSION["clickid"] = $_GET['clickid'];
?>

I then pass this out to a third party in an external link, for example test.php?&clickid=&campaign=.

However what l cannot seem to do is share this SESSION across the domain. This script works if you land on page A and click the link, however what l want to be able to do is the user to click the link, visit page X and page Y, return to the page A and the variables still be stored.

Can anyone help ?

  • 写回答

2条回答 默认 最新

  • dongluanguang4774 2014-09-01 12:38
    关注

    It appears you are overwritting your variables - if there are no get parameters.

    You should only write to session if the parameters exist:

    <?php
    session_start();
    
    if(isset($_GET['campaign'])){
        $_SESSION["campaign"] = $_GET['campaign'];
    }
    if(isset($_GET['clickid'])){
        $_SESSION["clickid"] = $_GET['clickid'];
    }
    
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记